Skip to content
Latchkey

cdk deploy Command Reference

Synthesize and deploy AWS CDK stacks to your AWS account.

cdk deploy synthesizes your CDK app to CloudFormation and deploys the resulting stacks. In CI you disable the security approval prompt so the deploy runs unattended.

What it does

cdk deploy runs synth, uploads assets, and creates or updates the CloudFormation stacks for your app. By default it pauses to confirm changes that affect security posture (IAM, security groups); CI must opt out of that prompt.

Common flags and usage

  • --require-approval never: never pause for security confirmation (required in CI)
  • --all: deploy every stack in the app
  • STACK_NAME: deploy a single named stack
  • --outputs-file FILE: write stack outputs to a JSON file
  • --context KEY=VALUE: pass synthesis context
  • --no-rollback: keep resources on failure for debugging (use sparingly)

Example

shell
- name: CDK Deploy
  env:
    AWS_REGION: us-east-1
  run: |
    npx cdk deploy --all \
      --require-approval never \
      --outputs-file cdk-outputs.json

In CI

Always pass --require-approval never, otherwise the deploy blocks on a security prompt and the job times out. Use GitHub OIDC to assume an AWS role rather than long-lived keys. Capture outputs with --outputs-file so later steps can read deployed values.

Key takeaways

  • cdk deploy synthesizes and applies your CDK stacks to AWS.
  • --require-approval never is mandatory in CI or the job hangs on a prompt.
  • Use OIDC for AWS credentials and --outputs-file to export stack outputs.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →