gpt4 book ai didi

amazon-web-services - "Unable to determine aws-region"运行本地 Cloudwatch 代理时

转载 作者:行者123 更新时间:2023-12-03 21:58:34 26 4
gpt4 key购买 nike

我正在尝试将 AWS Cloudwatch 代理配置为在 AWS 之外的 vanilla Ubuntu 18.04 上运行。每次我运行它,我都会收到这个错误:

# /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m onPremise -c "file:/path/to/cloudwatch/cloudwatch.json" -s
/opt/aws/amazon-cloudwatch-agent/bin/config-downloader --output-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --download-source file:/path/to/cloudwatch/cloudwatch.json --mode onPrem --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config default
Got Home directory: /root
I! Set home dir Linux: /root
Unable to determine aws-region.
Please make sure the credentials and region set correctly on your hosts.
Refer to http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
Fail to fetch the config!

strace -f 下运行程序显示它正在尝试读取 /root/.aws/credentials然后退出。根据指南,这里是 /root/.aws/credentials 的内容:
[AmazonCloudWatchAgent]
aws_access_key_id = key
aws_secret_access_key = secret
region = us-west-2

如果我运行 aws configure get region ,它能够正确检索区域。但是,Cloudwatch 代理无法读取它。这是 common-config.toml的内容(每个 strace 也可以读取)。
## Configuration for shared credential.
## Default credential strategy will be used if it is absent here:
## Instance role is used for EC2 case by default.
## AmazonCloudWatchAgent profile is used for onPremise case by default.
[credentials]
shared_credential_profile = "AmazonCloudWatchAgent"
shared_credential_file = "/root/.aws/credentials"


## Configuration for proxy.
## System-wide environment-variable will be read if it is absent here.
## i.e. HTTP_PROXY/http_proxy; HTTPS_PROXY/https_proxy; NO_PROXY/no_proxy
## Note: system-wide environment-variable is not accessible when using ssm run-command.
## Absent in both here and environment-variable means no proxy will be used.
# [proxy]
# http_proxy = "{http_url}"
# https_proxy = "{https_url}"
# no_proxy = "{domain}"

以下是我尝试过的其他事情:
  • region (和所有值)在双引号中的配置中,每 https://forums.aws.amazon.com/thread.jspa?threadID=291589 .这并没有什么不同。
  • 添加/home/myuser/.aws/config、/home/myuser/.aws/credentials 和/root/.aws/config 并使用适当的值填充它们。 Per strace 这些文件没有被读取。
  • 搜索 CloudWatch Agent 的源代码(它不是开源的)
  • 在程序环境中显式设置 AWS_REGION=us-west-2(相同错误)
  • 改变 [AmazonCloudWatchAgent][profile AmazonCloudWatchAgent]上面的所有地方和所有排列(没有区别)
  • 添加 [default]所有配置文件中的部分(没有区别)
  • 调用 config-downloader直接编程,设置AWS_REGION等(同样的错误)
  • 成为非 root 用户,然后使用 sudo 调用程序而不是在没有 sudo 的情况下以 root 用户身份调用程序.

  • 无论我尝试什么,我都会遇到同样的错误。根据这些说明,我于 2020 年 3 月 23 日通过下载“最新”deb 安装了 CloudWatch 代理。 https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/download-cloudwatch-agent-commandline.html

    最佳答案

    aws 配置默认为 C:\Users\Administrator,而不是您安装 CloudWatch 代理的用户。因此,您可能需要将/.aws/文件夹移动到 CLoudWatch 用户。或者……更直接:

    aws configure --profile AmazonCloudWatchAgent

    如此处所述: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-commandline-fleet.html#install-CloudWatch-Agent-iam_user-first

    您还可以使用 common-config.toml 指定区域如此处所述: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-commandline-fleet.html#CloudWatch-Agent-profile-instance-first

    On a server running Windows Server, this file is in the C:\ProgramData\Amazon\AmazonCloudWatchAgent directory. The default common-config.toml is as follows:


    # This common-config is used to configure items used for both ssm and cloudwatch access


    ## Configuration for shared credential.
    ## Default credential strategy will be used if it is absent here:
    ## Instance role is used for EC2 case by default.
    ## AmazonCloudWatchAgent profile is used for onPremise case by default.
    # [credentials]
    # shared_credential_profile = "{profile_name}"
    # shared_credential_file= "{file_name}"

    ## Configuration for proxy.
    ## System-wide environment-variable will be read if it is absent here.
    ## i.e. HTTP_PROXY/http_proxy; HTTPS_PROXY/https_proxy; NO_PROXY/no_proxy
    ## Note: system-wide environment-variable is not accessible when using ssm run-command.
    ## Absent in both here and environment-variable means no proxy will be used.
    # [proxy]
    # http_proxy = "{http_url}"
    # https_proxy = "{https_url}"
    # no_proxy = "{domain}"

    如果需要,您还可以使用新位置更新 common-config.toml。

    关于amazon-web-services - "Unable to determine aws-region"运行本地 Cloudwatch 代理时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60835513/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com