Fri Apr 23 2021·2 min read
Photo by Andreas Dress
Updated on Fri Apr 23 2021
The CDK deploy command deploys our CDK stack(s) as CloudFormation template(s).
The syntax of the command looks like:
npx cdk deploy
When deploying more than one stack, it's better to explicitly specify the stack names:
npx cdk deploy \ my-stack-dev \ my-stack-prod
CDK is just an abstraction level above CloudFormation. The whole idea behind CDK
is to improve developer experience by allowing us to use a programming language,
rather than a configuration language like
Our CDK code eventually gets compiled down to CloudFormation code before a deployment is executed.
When we call the
cdk deploy command a couple of things happen behind the
cdk synth command is called. It executes our CDK app and synthesizes a
CloudFormation template in the
cdk.out directory contains our asset files and the CloudFormation
template. An example of asset files would be the code required for a Lambda
We can look at the
cdk.out directory as a preparation step before
Next, our assets code and the CloudFormation template will be deployed to an S3
bucket, that was provisioned with the
cdk bootstrap command.
We only have to run
cdk bootstrap once per environment (account and region)
and it provisions a CloudFormation stack, called
CDKToolkit stack consists of an S3 bucket that stores our asset files:
If we have our environment bootstrapped the CDK CLI then deploys our asset files to the S3 bucket:
After our assets are globally available via an S3 bucket our CloudFormation template is deployed / updated.
cdk deploy command generates and then deploys the CloudFormation
equivalent of our CDK code.
Note that it's not necessary to run the
cdk synth command before we run
cdk deploy, because the CDK CLI will automatically synthesize a CloudFormation
template for each stack before deployment.
I'll send you 1 email a week with links to all of the articles I've written that week