cdk deploy: Usage, Options & Common CI Errors
Synthesize and deploy your AWS CDK stacks via CloudFormation.
cdk deploy synthesizes your CDK app to CloudFormation and deploys the stacks. In CI you disable the interactive approval prompt and must have bootstrapped the target account/region first.
What it does
cdk deploy runs cdk synth internally to produce CloudFormation templates, then creates or updates the stacks via CloudFormation change sets. By default it prompts before deploying changes that affect security/IAM; in CI you suppress that prompt with --require-approval never.
Common usage
# Deploy one stack
cdk deploy MyStack
# CI: deploy all stacks with no approval prompt
cdk deploy --all --require-approval never
# Pass context and produce stack outputs for later steps
cdk deploy MyStack --context env=prod --outputs-file cdk-outputs.jsonCommon error in CI: environment not bootstrapped
deploy fails with "This stack uses assets, so the toolkit stack must be deployed ... Please run 'cdk bootstrap'" or "SSM parameter /cdk-bootstrap/.../version not found". The account/region was never bootstrapped (no CDKToolkit stack / staging bucket). Fix: run cdk bootstrap aws://<account>/<region> once per account+region (with credentials that can create the bootstrap resources), then deploy. In CI also pass --require-approval never so an IAM-affecting change does not hang on a prompt.
Key options
| Option | Purpose |
|---|---|
| --all | Deploy every stack in the app |
| --require-approval never | Skip the security prompt (CI) |
| --context KEY=VAL | Pass context values |
| --outputs-file FILE | Write stack outputs to JSON |
| --hotswap | Fast dev deploy (skips CloudFormation where possible) |