我们有 2 个 aws 账户。现在我们尝试将生产环境资源迁移到另一个 aws 账户。我们在账户 A 中设置了管道,它将在账户 B 中部署资源。 我们的 AWS 基础设施堆栈已在帐户 B 中可用,并且在从帐户 A 运行以下 cmd 时,我们收到以下错误:-
cmd:- aws cloudformation 描述堆栈 --stack-name prod-gateway
错误:- 调用DescribeStacks操作时发生错误(ValidationError):ID为prod-gateway的堆栈不存在
这是一个有效的错误,因为我们正在尝试从帐户 A 获取帐户 B 堆栈信息,而帐户 A 中不存在该堆栈。
所以问题是我可以从帐户 A 描述帐户 B 的堆栈信息吗?有没有跨帐户cmd来实现这一点?
最佳答案
So the question is can I describe the stack info of account B from account A ? is there any cross account cmd to achieve this ?
您为此使用 cross-account roles您必须设置的角色。简而言之:
- 在 accB 中,您创建一个允许描述其堆栈的角色。该角色的信任关系允许 accA 承担该角色。
- 在 accA 中,您使用 assume-role接替 accB 的角色。这将为您提供新的临时 AWS 凭证。 accB 中的 IAM 角色/用户必须具有代入该角色的权限。
- 在 accA 中,您可以使用临时凭证针对 accB 执行
aws cloudformation describe-stacks
。
关于amazon-web-services - 如何描述cloudformation跨帐户堆栈信息/名称/详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66904554/