AWS CLI不遵守默认区域配置

时间:2020-06-16 13:19:38

标签: amazon-web-services aws-cli

我在~/.aws/config文件中设置了默认区域:

[default]
region=us-west-2

但是,当我尝试使用某些特定配置文件的describe-instances命令时,它失败并显示以下消息:

$ aws ec2 describe-instances --profile my_profile
You must specify a region. You can also configure your region by running "aws configure".

它不应该使用~/.aws/config文件中配置的默认配置文件吗?我在这里想念什么?

aws configure list的输出:

      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ******************** shared-credentials-file
secret_key     ******************** shared-credentials-file
    region                us-west-2      config-file    ~/.aws/config

aws configure list --profile my_profile

的输出
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                my_profile           manual    --profile
access_key     ******************** shared-credentials-file
secret_key     ******************** shared-credentials-file
    region                <not set>             None    None

p.s。 AWS的新功能。如果这是一个非常基本的问题,请原谅我。

1 个答案:

答案 0 :(得分:3)

您正在使用named profiles,默认情况下使用default配置文件。就像您configure的默认设置一样,您可以/需要配置个人资料。

aws configure --profile my_profile

它会提示您填写hereaccess keysecret access keyAWS Regionoutput format

您可以通过指定--profile选项并分配名称来创建可以用名称引用的其他配置。以下示例创建一个名为produser的配置文件。您可以从与其他配置文件完全不同的帐户和区域中指定凭据。