Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Purpose and scope of AWS CDK bootstrap stack?

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

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?
like image 278
John Avatar asked Feb 21 '20 23:02

John


People also ask

What does AWS CDK bootstrap do?

cdk bootstrap is a tool in the AWS CDK command-line interface responsible for populating a given environment (that is, a combination of AWS account and region) with resources required by the CDK to perform deployments into that environment.

What is AWS bootstrapping?

Bootstrapping is the deployment of a AWS CloudFormation template to a specific AWS environment (account and region). The bootstrapping template accepts parameters that customize some aspects of the bootstrapped resources (see Customizing bootstrapping).

Why do we use AWS CDK?

CDK allows you to use your existing skills and tools, applying them to the task of building cloud infrastructure. It also provides high-level components that preconfigure cloud resources with proven defaults, helping you build on AWS without needing to be an expert.

Does bootstrap need CDK?

Using CDK bootstrap #We only need to use the bootstrap command once for every environment(region and account). If we use the command more than once, the CDK CLI will check if our CDKToolkit stack has to be updated. If necessary, the stack will be updated. If not, running the bootstrap command does nothing.


1 Answers

background:

cdk bootstrap is a tool in the AWS CDK command-line interface responsible for populating a given environment (that is, a combination of AWS account and region) with resources required by the CDK to perform deployments into that environment.

When you run cdk bootstrap cdk deploys the CDK toolkit stack into an AWS environment.

The bootstrap command creates a CloudFormation stack in the environment passed on the command line. Currently, the only resource in that stack is An S3 bucket that holds the file assets and the resulting CloudFormation template to deploy.

cdk bootstrap command is running one time per account/ region.

Simple scenario to sum-up:

  1. Run cdk bootstrap - create a new s3 bucket, IAM roles, etc.
  2. Run cdk deploy - to deploy your stack for the first time, new template added to bootstrap s3 bucket.
  3. Apply any change to cdk stack.
  4. Run cdk diff - to view differences -

Behind the scenes, CDK generates the new template and compare it with the CDK template that exists in the bootstrap bucket.

More about cdk bootstrap.

like image 92
Amit Baranes Avatar answered Sep 27 '22 17:09

Amit Baranes