首页 > 解决方案 > aws cli 没有在一个配置文件的源配置文件中找到区域,但可以与另一个配置文件一起使用

问题描述

我有一个~/.aws/config看起来像这样的东西:

[default]
region = us-east-1

[profile foo]
region = us-east-1

[profile foo-iam-manager]
    role_arn = arn:aws:iam::012345678984:role/iam-manager
    source_profile = foo

[profile foo-secrets-manager]
    role_arn = arn:aws:iam::012345678984:role/secrets-manager
    source_profile = foo

如果我运行:

aws --profile foo-iam-manager iam list-roles

效果很好!

但是如果我运行:

aws --profile foo-secrets-manager secretsmanager list-secrets

然后它失败了:

You must specify a region. You can also configure your region by running "aws configure".

事实上,如果我更新~/.aws/config看起来像......

[default]
region = us-east-1

[profile foo]
region = us-east-1

[profile foo-iam-manager]
    role_arn = arn:aws:iam::012345678984:role/iam-manager
    source_profile = foo

[profile foo-secrets-manager]
    role_arn = arn:aws:iam::012345678984:role/secrets-manager
    source_profile = foo
    region = us-east-1

...然后一切正常。为什么foo-iam-manager配置文件在配置文件中没有区域设置的情况下工作得很好,但 foo-secrets-manager需要一个?我认为它会从设置中提取适当的值source_profile

标签: amazon-web-services

解决方案


推荐阅读