我正在尝试使用CLI从其他AWS账户访问Cognito用户池。我可以从API网关(将用户池设置为授权者)执行此操作,但从CLI只能说此用户池不存在。有没有一种方法可以告诉CLI在与我所在的帐户不同的帐户中查找用户池?如果我换了角色,可以这样做,但是我希望避免这种情况。
答案 0 :(得分:0)
您可以指定一个配置文件(https://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html),而不是切换角色。
例如,在~/.aws/config
中,您可能会:
[profile another]
role_arn = arn:aws:iam::account:role/OrganizationAccountAccessRole
source_profile = default
(n.b。您的role_arn应该是您的跨帐户角色arn实际上是什么)
然后,您可以在cli中使用--profile
参数来承担其他角色,而不会影响其他命令&c。
例如:
aws cognito-idp initiate-auth --client-id=$CLIENT_ID --auth-flow='USER_PASSWORD_AUTH' --profile=another --region=eu-west-2 --auth-parameters USERNAME='me@example.com',PASSWORD='password'