使用 AWS CDK V2 进行部署时,有什么方法可以使用单个角色吗?就像 V1 一样

Is there any way to use a single role when deploying with AWS CDK V2 ? Just as it was with V1

我正在尝试将我公司的项目从 CDK V1 升级到 CDK V2。

我在部署到 CloudFormation 时遇到问题,因为我的公司对 IAM 角色和命名约定有严格的规定。

考虑到单个角色足以构建和部署所有内容到 CloudFormation,CDK V1 一切正常。

使用 CDK V2,现在有必要通过 bootstrap(由于这些限制,我手动完成但这里没有问题)创建不同的 IAM 角色,并将它们与 StackSynthesizer 一起使用。

问题是:在不违反我公司规定的情况下,这些角色不能以任何方式担任iam:PassRole。当我的角色“deploy”试图允许我的角色“cfn-exec”将所有内容放在 CloudFormation 上时,我收到一个错误。

那么,在每个“cdk 部署”步骤中使用单个角色的同时,有没有什么方法可以使用 CDK V2 绕过 iam:PassRole?就像 CDK V1 一样。

请注意,在每个 StackSynthesizer 属性 中放置一个角色不会绕过 iam:PassRole 默认行为。

有几个合成器选项不使用通常的现代引导角色。

  1. LegacyStackSynthesizer

This synthesizer will generate CloudFormation parameters for every referenced asset, and use the CLI's current credentials to deploy the stack.

  1. CliCredentialsStackSynthesizer(首选)

A synthesizer that uses conventional asset locations, but not conventional deployment roles.

Instead of assuming the bootstrapped deployment roles, all stack operations will be performed using the CLI's current credentials.

选项 2 应该适合您的 use-case。