MIKAEELS

Explore the blog

What Does the AWS CDK Bootstrap Command Do?

The AWS Cloud Development Kit (CDK) is a software development framework for defining cloud infrastructure as code. The CDK Bootstrap command is a key part of the CDK tooling that sets up your AWS environment to use the CDK. In this post, we'll explore what the CDK Bootstrap command does and provide an example of how to use it.

When you first start using the CDK, you need to run the Bootstrap command to set up your environment. This command creates a CloudFormation stack in your AWS account that contains the necessary permissions and resources for the CDK to deploy your infrastructure. The command is typically run once per AWS account and region.

Modern bootstrapping creates an S3 asset bucket, an ECR asset repository, IAM roles for deployment and asset publishing, and a bootstrap-version parameter. Names depend on the bootstrap qualifier, account, region, and customization; do not assume a universal role named AWSCDKBootstrapRole.

Treat bootstrap as a cloud infrastructure change. Review its template and permissions before running it; do not rely on an interactive confirmation prompt as the review boundary. Existing bootstrap stacks may also need an upgrade when your CDK tooling requires a newer template version. See the official bootstrapping guide.

Here is an example of how to use the CDK Bootstrap command to set up an environment for the us-east-1 region:

cdk bootstrap --region us-east-1

It's also possible to pass an explicit profile name, as well as other parameters.

cdk bootstrap --profile my-profile --region us-east-1

Note: The bootstrap command requires AWS CLI credentials to be configured and it will use the default profile if no profile is specified.

Additionally, it's important to mention that, this command will also create a CloudFormation Stack named CDKToolkit which contains the necessary permissions and resources for the CDK to interact with your AWS environment.

In this post, we've discussed what the AWS CDK Bootstrap command does and provided an example of how to use it to set up your AWS environment for use with the CDK. The bootstrap command is a critical step in getting started with the CDK and should be run before you deploy any CDK infrastructure.

Continue reading

What does CDK Synth do in AWS CDK · How to Deploy All Stacks in AWS CDK

Quick Recap

What does cdk bootstrap do?

cdk bootstrap provisions the resources CDK needs to deploy applications into an AWS account and region, including an S3 bucket for templates, an IAM role, and the CDKToolkit CloudFormation stack.

How often do I need to run cdk bootstrap?

Typically once per AWS account and region combination. It doesn't need to be repeated for every deployment or every stack.

What is the CDKToolkit stack?

CDKToolkit is the CloudFormation stack created by cdk bootstrap. It contains the S3 bucket, IAM roles, and other resources the CDK CLI uses to deploy your application stacks.

Can I bootstrap a specific region or profile?

Yes, pass --region and --profile flags, e.g. cdk bootstrap --profile my-profile --region us-east-1, to bootstrap a non-default account/region combination.

Add Mikaeels Blog as a preferred source on Google

Comments

Share your thoughts and questions below