Purpose and scope of AWS CDK bootstrap stack?

Joh*_*ohn 3 amazon-web-services aws-cdk

The docs on AWS CDK boostrapping state of the cdk bootstrap command:

cdk bootstrap
Deploys a CDKToolkit CloudFormation stack into the specified environment(s), that provides an S3 bucket that cdk deploy will use to store synthesized templates and the related assets, before triggering a CloudFormation stack update. The name of the deployed stack can be configured using the --toolkit-stack-name argument.

$ # Deploys to all environments
$ cdk bootstrap --app='node bin/main.js'

$ # Deploys only to environments foo and bar
$ cdk bootstrap --app='node bin/main.js' foo bar
Run Code Online (Sandbox Code Playgroud)

However, how often does CDK need to be bootstrapped? Is it:

  • once for each AWS account?
  • once for each application in each AWS account?
  • once for each application in each AWS account that requires assets?
  • something else?

Ami*_*nes 8

关于引导程序的一些背景:

cdk bootstrap 是 AWS CDK 命令行界面中的一个工具,负责使用 CDK 在该环境中执行部署所需的资源填充给定环境(即 AWS 账户和区域的组合)。

当您运行cdk bootstrapcdk时,会将 CDK 工具包堆栈部署到 AWS 环境中。

bootstrap 命令在命令行传递的环境中创建一个 CloudFormation 堆栈。目前,该堆栈中的唯一资源是一个 S3 存储桶,其中包含要部署的文件资产和生成的 CloudFormation 模板。

cdk bootstrap 命令在每个帐户/区域运行一次。

简单的场景总结:

  1. 运行cdk bootstrap- 创建新的 s3 存储桶、IAM 角色等。
  2. 运行cdk deploy- 首次部署您的堆栈,新模板已添加到 bootstrap s3 存储桶。
  3. 对 cdk 堆栈应用任何更改。
  4. 运行cdk diff- 查看差异 -

在幕后,CDK 生成新模板并将其与引导存储桶中存在的 CDK 模板进行比较。

更多关于cdk bootstrap

  • @Vijay 据我所知,不。cdk bootstrap 仅适用于新堆栈 (2认同)