(1) Install AWS CDK

npm i -g aws-cdk

(2) Create a template

cdk init --language typescript

When you initialize the project, it creates a bunch of files with all the configuration done. It has App and Stack.

- bin
- myapp.ts
- lib
- constructs
- mykinesis.ts
- mylambda.ts
- stacks
- mysimplestack.ts

(3) Compile the app

install S3 and Dynamodb construct libraries from npm:

npm install @aws-cdk/aws-s3@aws-cdk/aws-dynamodb

Now compile app

npm run build

(4) List the stacks in the app

cdk ls

(5) Synthesizing CloudFormation template

cdk synth

(6) Deploying

You can use the cdk bootstrap command to install the bootstrap stack into an environment:

cdk bootstrap

Use cdk deploy to deploy a CDK app:

cdk deploy

(7) Checking diff

cdk diff

(8) Deleting the stack

cdk destroy