LinuxCommandLibrary

cdk

AWS Cloud Development Kit CLI

TLDR

Initialize new CDK project

$ cdk init app --language [typescript]
copy
List stacks in app
$ cdk list
copy
Synthesize CloudFormation template
$ cdk synth
copy
Deploy stack
$ cdk deploy [StackName]
copy
Deploy all stacks
$ cdk deploy --all
copy
Show diff with deployed stack
$ cdk diff [StackName]
copy
Destroy stack
$ cdk destroy [StackName]
copy

SYNOPSIS

cdk [globaloptions] command [arguments] [commandoptions]

DESCRIPTION

cdk is the AWS Cloud Development Kit CLI for defining cloud infrastructure as code using familiar programming languages. It synthesizes CloudFormation templates from TypeScript, Python, Java, C#, or Go code and deploys them to AWS.
Instead of writing CloudFormation YAML or JSON by hand, developers define infrastructure using constructs -- reusable, composable classes that represent AWS resources. The CDK synthesizes these constructs into CloudFormation templates, which are then deployed to create and manage the actual AWS resources.
The workflow typically involves initializing a project with `cdk init`, writing infrastructure code, previewing changes with `cdk diff`, and deploying with `cdk deploy`. The `cdk watch` command enables hot-reloading during development.

PARAMETERS

--all

Deploy/destroy all stacks
--hotswap
Fast deployment when possible
--require-approval level
Approval level: never, any-change, broadening
--profile name
AWS profile to use
--region region
AWS region
--output dir
Output directory for synthesized templates
--verbose, -v
Verbose output

CONFIGURATION

cdk.json

Project configuration including app entry point, context values, and feature flags.

COMMANDS

init

Create new CDK project from template
list (ls)
List stacks in CDK app
synth
Synthesize CloudFormation template
deploy
Deploy stacks to AWS
destroy
Delete stacks from AWS
diff
Show differences between stacks
bootstrap
Deploy CDK bootstrap stack
watch
Watch for changes and deploy
context
Manage cached context values
docs
Open CDK documentation

CAVEATS

Requires Node.js and AWS credentials configured. Run `cdk bootstrap` once per account/region before first deploy.

SEE ALSO

aws(1), terraform(1), pulumi(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community