← 返回命令列表

Linux command

cdk 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Initialize new CDK project

cdk init app --language [typescript]

List stacks in app

cdk list

Synthesize CloudFormation template

cdk synth

Deploy stack

cdk deploy [StackName]

Deploy all stacks

cdk deploy --all

Show diff with deployed stack

cdk diff [StackName]

Destroy stack

cdk destroy [StackName]

说明

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.

参数

--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

FAQ

What is the cdk command used for?

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.

How do I run a basic cdk example?

Run `cdk init app --language [typescript]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --all do in cdk?

Deploy/destroy all stacks