💥 Breaking Change: Updating to CDK v2
We migrated to CDK v2. Here is how to update your apps.
Estimated time: 15 minutes
Prerequisites
- Update Node.js to v14 or later
- Update SST to v0.57.0 or later
Steps
-
Run
npx sst update 0.59.1
-
Open up your
package.json
and update CDK dependencies to v2.- If you have
@aws-cdk/core
as a dependency, rename it toaws-cdk-lib
. - If you have
@aws-cdk/assert
as a dependency, remove it from your package.json. - If you have one or more
@aws-cdk/aws-XXXX
dependencies, and if they are on the experimental package list below, rename them to@aws-cdk/aws-XXXX-alpha
. For example, rename@aws-cdk/api-gatewayv2
to@aws-cdk/api-gatewayv2-alpha
. - If you have one or more
@aws-cdk/aws-XXXX
dependencies, and if they are not on the experimental package list below, remove them from your package.json.
- If you have
-
Update the
import
in your CDK code to use v2 dependencies.- If you import
@aws-cdk/core
, renameimport * as cdk from "@aws-cdk/core"
toimport * as cdk from "aws-cdk-lib"
. - If you import
@aws-cdk/assert
, renameimport * as assert from "@aws-cdk/assert"
toimport * as assert from "aws-cdk-lib/assertions"
. Read more about using assertions here. - If you import
@aws-cdk/aws-XXXX
, and if they are on the experimental package list below, renameimport * as XXXX from "@aws-cdk/aws-XXXX"
toimport * as XXXX from "@aws-cdk/aws-XXXX-alpha"
. For example, renameimport * as apig from "@aws-cdk/aws-apigatewayv2"
toimport * as apig from "@aws-cdk/aws-apigatewayv2-alpha"
. - If you have one or more
@aws-cdk/aws-XXXX
dependencies, and if they are not on the experimental package list below, renameimport * as XXXX from "@aws-cdk/aws-XXXX"
toimport * as XXXX from "aws-cdk-lib/aws-XXXX"
. For example, renameimport * as sns from "@aws-cdk/aws-sns"
toimport * as sns from "aws-cdk-lib/aws-sns"
.
- If you import
-
Run
npx sst update 0.59.1
one more time. -
Run
npx sst diff
to review the changes. If you are updating from SST v0.57.0 or later, the only major change is how CDK v2 handles CloudFormation parameters, which mostly affectsAWS::Lambda::Function
resources'Code
properties.
Read more about updating to AWS CDK v2 here
Experimental packages
@aws-cdk/aws-amplify
@aws-cdk/aws-apigatewayv2
@aws-cdk/aws-apigatewayv2-authorizers
@aws-cdk/aws-apigatewayv2-integrations
@aws-cdk/aws-apprunner
@aws-cdk/aws-appsync
@aws-cdk/aws-batch
@aws-cdk/aws-cloud9
@aws-cdk/aws-codestar
@aws-cdk/aws-glue
@aws-cdk/aws-iot-actions
@aws-cdk/aws-iot
@aws-cdk/aws-iotevents
@aws-cdk/aws-ivs
@aws-cdk/aws-kinesisanalytics-flink
@aws-cdk/aws-kinesisfirehose
@aws-cdk/aws-kinesisfirehose-destinations
@aws-cdk/aws-lambda-go
@aws-cdk/aws-lambda-python
@aws-cdk/aws-msk
@aws-cdk/aws-neptune
@aws-cdk/aws-redshift
@aws-cdk/aws-route53resolver
@aws-cdk/aws-servicecatalog
@aws-cdk/aws-servicecatalogappregistry
@aws-cdk/aws-synthetics