AWS Cloud Development Kit (CDK) lets you define AWS infrastructure using programming languages such as TypeScript, Python, Java, C#, and Go instead of writing CloudFormation YAML/JSON manually.
Write CDK Code
↓
cdk synth
↓
CloudFormation Template (cdk.out/)
↓
cdk diff (optional)
↓
Shows changes
↓
cdk deploy
↓
Deploys to AWScdk synthPurpose: Generate (synthesize) the CloudFormation template.
cdk.out/ directory.Exam Tip:
"Generate CloudFormation template" =
cdk synth
cdk deployPurpose: Deploy the infrastructure.
Exam Tip:
Deploy infrastructure =
cdk deploy
cdk diffPurpose: Compare changes.
Exam Tip:
View changes before deployment =
cdk diff
cdk buildThere is no standard CDK command called cdk build.
npm run build or tsc to compile TypeScript.Exam Tip:
Compiling code ≠ Synthesizing CloudFormation
| Command | Purpose |
|---|---|
cdk synth |
Generate CloudFormation template (cdk.out) |
cdk diff |
Show differences between deployed stack and local code |
cdk deploy |
Deploy CloudFormation stack to AWS |
cdk destroy |
Delete deployed stack |
Which command generates a CloudFormation template that can be reviewed before deployment?
✅ Answer: cdk synth
Because it converts the CDK application into a CloudFormation template and stores it in the cdk.out/ directory before anything is deployed.