AWS CDK CLI
$ cdk Official High RiskAWS CDK CLI (cdk) synthesizes TypeScript, Python, Go, Java, or C# infrastructure code into CloudFormation templates (cdk synth), previews exact infrastructure changes (cdk diff), and deploys stacks with configurable IAM approval gates.
npm install -g aws-cdk cdk executes local project code to run synth and diff, making local CLI execution essential over remote MCP.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Supports --ci, --no-color, and machine-readable cdk.out CloudFormation JSON artifacts, though cdk diff stdout is human-formatted.
- Supports
--ci,--no-color, and JSON template synthesis incdk.out
cdk synth is 100% local, cdk diff shows exact changes, and --require-approval broadening blocks unexpected IAM expansion.
- Built-in
--require-approvalIAM safety check andcdk diff
Easy npm install -g aws-cdk or npx aws-cdk invocation, though project language runtimes must also be installed.
- Official npm
aws-cdkpackage andnpxsupport
Bridges high-level TypeScript/Python IaC directly to CloudFormation.
- Synthesizes and diffs multi-stack AWS apps
First-party AWS tool (aws/aws-cdk-cli) updated continuously.
- Official AWS CDK CLI under Apache-2.0
Detailed CDK Developer Guide and --help flags.
- AWS CDK v2 CLI reference
Security, Auth & Guardrails
Reads standard AWS credentials from ~/.aws/credentials, AWS_PROFILE, or environment keys.
CLI is free (Apache-2.0); deployed AWS stacks incur cloud billing.
# AWS CDK Agent Rules - ALWAYS run `cdk synth --no-color --ci` and `cdk diff --no-color --ci` before any deploy. - Keep `--require-approval broadening` (default) enabled; never pass `--require-approval never` automatically. - Avoid `cdk destroy` without explicit user confirmation.
Agent-Ready Command Recipes
Safe Read-Only Queries
cdk synth --no-color --ci
Compiles CDK constructs into cdk.out/ CloudFormation JSON/YAML with zero AWS mutations.
cdk diff --no-color --ci
Previews resource additions, replacements, and IAM policy changes before deployment.
Controlled Writes & Previews
cdk deploy MyAppStack --require-approval broadening --ci --no-color
Aborts automatically if IAM permissions would broaden unless approved.
Strengths for Agents
- +
cdk synthandcdk diffprovide clear pre-deployment verification. - +
--require-approval broadeningblocks silent IAM privilege escalation. - +
--ciand--no-colorcleanly format output for non-TTY logs.
Caveats & Pitfalls
- !
cdk diffandcdk deploylack a--jsonstructured output mode. - ! Requires matching Node.js plus the CDK app's target language runtime.