Migrating to AWS CDK v2 - AWS Cloud Development Kit (AWS CDK) v1

This is the AWS CDK v1 Developer Guide. The older CDK v1 entered maintenance on June 1, 2022 and will now only receive critical bug fixes and security patches. New features will be developed for CDK v2 exclusively. Support for CDK v1 will end entirely on June 1, 2023. Migrate to CDK v2 to have access to the latest features and fixes.

Migrating to AWS CDK v2

Version 2 of the AWS CDK provides an improved development experience that aims to make Infrastructure as Code (IAC) even simpler.

CDK v1 entered maintenance on June 1, 2022. During the maintenance phase, CDK v1 will receive critical bug fixes and security patches only, and new features will be developed exclusively for CDK v2. On June 1, 2023, support will end entirely for AWS CDK v1. For more details, see AWS CDK Maintenance Policy.

For information on migrating your apps to AWS CDK v2, see Migrating to AWS CDK v2 in the AWS CDK v2 Developer Guide.

Tip

To identify stacks deployed with AWS CDK v1, use the awscdk-v1-stack-finder utility.

CDK Toolkit v2 compatibility

CDK v2 requires v2 or later of the CDK Toolkit. This version is backward-compatible with CDK v1 apps, so you can use a single globally-installed version of CDK Toolkit with all your AWS CDK projects, whether they use v1 or v2. An exception is that CDK Toolkit v2 only creates CDK v2 projects.

If you need to create both v1 and v2 CDK projects, do not install CDK Toolkit v2 globally. (Remove it if you already have it installed: npm remove -g aws-cdk.) To invoke the CDK Toolkit, use npx to run v1 or v2 of the CDK Toolkit as desired.

npx aws-cdk@1.x init app --language typescript npx aws-cdk@2.x init app --language typescript
Tip

Set up command line aliases so you can use cdk and cdk2 commands to invoke the desired version of the CDK Toolkit.

macOS/Linux
alias cdk="npx aws-cdk@1.x" alias cdk2="npx aws-cdk@2.x"
Windows
doskey cdk=npx aws-cdk@1.x $* doskey cdk2=npx aws-cdk@2.x $*