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.
The CDK Bootstrap command creates an S3 bucket and an IAM role that are used to store the CloudFormation templates that the CDK generates. The command also creates a set of permissions that allow the CDK to create and manage resources in your AWS account. The IAM role created by the bootstrap command is named
AWSCDKBootstrapRole and it has permission to create, update, and delete CloudFormation stacks, as well as read and write to the S3 bucket.
When you run the bootstrap command it will show you the details of what it will create and prompt for confirmation before creating it.
Here is an example of how to use the CDK Bootstrap command to set up an environment for the
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.
Did you find this article valuable?
Support Mikaeel Khalid by becoming a sponsor. Any amount is appreciated!