【发布时间】:2020-09-08 06:38:16
【问题描述】:
我正在尝试使用 CDK 和 CodePipeline 设置跨账户部署管道。
我从 AWS Docs 构建了示例 CodePipeline 示例,并且能够使用 cdk 成功部署到单个账户中。 (https://docs.aws.amazon.com/cdk/latest/guide/codepipeline_example.html)
$ cdk deploy PipelineDeployingLambdaStack --profile=111111111111
这样就成功返回了。
然后使用 cdk-codepipeline-actions 文档中的跨帐户说明,我将 account 属性添加到我的部署操作中。
(https://docs.aws.amazon.com/cdk/api/latest/docs/aws-codepipeline-actions-readme.html#cross-account-actions)
{
stageName: 'Deploy',
actions: [
new codepipeline_actions.CloudFormationCreateUpdateStackAction({
account: '222222222222', // introduce cross-account deployment
......
}),
],
},
在此更改并再次运行 cdk synth 后,它会按预期生成一个名为 cross-account-support-stack-222222222222.template.json 的新堆栈。
到目前为止一切顺利。
当我尝试运行 cdk deploy 时,它会立即引发跨账户引用错误:
$ cdk deploy PipelineDeployingLambdaStack --profile=111111111111
Including dependency stacks: cross-account-support-stack-222222222222
cross-account-support-stack-222222222222 (PipelineDeployingLambdaStack-support-222222222222)
cross-account-support-stack-222222222222 (PipelineDeployingLambdaStack-support-222222222222): deploying...
❌ cross-account-support-stack-222222222222 (PipelineDeployingLambdaStack-support-222222222222) failed: Error: Need to perform AWS calls for account 222222222222, but the current credentials are for 111111111111.
我不明白这应该如何工作,因为我一次只能提供一组凭据。我找不到任何关于它的文档,这让我认为它应该是显而易见的。
我错过了什么?
【问题讨论】: