Skip to content
Latchkey

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

Terminal
# 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.json

Common 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

OptionPurpose
--allDeploy every stack in the app
--require-approval neverSkip the security prompt (CI)
--context KEY=VALPass context values
--outputs-file FILEWrite stack outputs to JSON
--hotswapFast dev deploy (skips CloudFormation where possible)

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →