docs
Initial Deployment
CDK
CDK Bootstrap

Bootstrapping Your AWS CDK Environment 🚀

Before deploying your AWS CDK applications, you need to bootstrap your AWS environment. Bootstrapping sets up the necessary resources that the CDK requires to deploy your stacks.

What is CDK Bootstrap?

The AWS CDK uses a CloudFormation stack, known as the bootstrap stack, to provision resources needed for deploying CDK applications. This includes an S3 bucket for storing assets (like deployment files) and an ECR repository for container images.

cdk bootstrap --qualifier [qualifier name] --profile [profile name]
  • --qualifier: must be an alphanumeric identifier of at most 10 characters. It creates bootstrapped resources (like the S3 bucket) with the prefix qualifier name. This ensures that the bootstrap resources used by this CDK environment are unique.

⚠️ The [qualifier name] MUST match the const appName value in the cdk/bin/cdk.ts file.

** must be an alphanumeric identifier of at most 10 characters ** Create Permission Set

Let's Bootstrap!

Make sure you are in the cdk directory. Let's run bootstrap for production first.

For Production Environment

Let's run

cdk bootstrap --qualifier launchgoat --profile awslaunchgoat-prod

⚠️ If you run into this error:

SSOTokenProviderFailure: SSO Token refresh failed. Please log in using "aws sso login"

Then refer to this.

⚠️ If you run into this error:

This CDK CLI is not compatible with the CDK library used by your application. Please upgrade the CLI to the latest version.

Then refer to this.


Bootstraping won't take that long..

Create Permission Set

Once done, you will see:

✅  Environment aws://account-id/us-east-1 bootstrapped.

Great! Successfully bootstrapped. Let's bootstrap the staging environment. Before you run the command, you need to do 2 things.

  1. update .env
  • Go back to the .env file in the cdk folder. Comment out the Production section and uncomment the Staging section.
  1. run sso login for staging
aws sso login --profile awslaunchgoat-staging

For Staging Environment

cdk bootstrap --qualifier launchgoat --profile awslaunchgoat-staging

Once done, we can now run cdk deploy command!