Get Started with AWS CDK
GETTING STARTED GUIDE
Module 2: Install the AWS Cloud Development Kit (CDK)
In this module, you will install and configure the AWS CDK
Before you start your work with the AWS CDK, you need to have its toolkit (CLI) ready and available on your workstation. This tool will be the link between the code you write and the infrastructure you provision, so it is important to have it set up and using the latest version. Additionally, once the CLI is configured, you will need to bootstrap your account so CDK can deploy resources to it properly. The bootstrapping process creates resources required for the CDK to operate correctly.
What You Will Learn
- Installing the AWS CDK CLI (Toolkit)
- Bootstrapping your AWS Account
Installing the AWS CDK CLI
To install the AWS CDK CLI, you need to first have the Node Package Manager (npm) installed. Install the AWS CDK CLI globally by running the following command:
npm install -g aws-cdk
To verify that it has been successfully installed run the following command:
Bootstrapping your AWS Account
Many AWS CDK stacks that you will deploy, will include assets, external files that are deployed with the stack, such as AWS Lambda functions or Docker images. The CDK uploads these to an Amazon S3 bucket or other containers so they are available to AWS CloudFormation during deployment. Deployment requires that these containers already exist in the AWS account and the region you are deploying into. Creating these containers is called bootstrapping. To bootstrap your AWS account (and a given region), run the following:
# Get the account ID aws sts get-caller-identity # Bootstrap the account cdk bootstrap aws://ACCOUNT-NUMBER/REGION
The bootstrap command should look something like this:
cdk bootstrap aws://123456789012/us-east-1 # Output ⏳ Bootstrapping environment aws://123456789012/us-east-1... CDKToolkit: creating CloudFormation changeset... ✅ Environment aws://328159166015/us-west-2 bootstrapped.
If you wish to use different accounts and regions, make sure to bootstrap each of those.
This should take care of everything you need to start working with AWS CDK. Once you have the CLI installed and the AWS Account and region combination bootstrapped, you can start writing and deploying some infrastructure.