AWS CDK Development
Guidance for building AWS infrastructure with the Cloud Development Kit (CDK) in
TypeScript or Python. Pairs well with AWS MCP servers for fetching current AWS
facts beyond the knowledge cutoff.
When to use
- Creating or refactoring CDK stacks / constructs
- Implementing Lambda functions inside CDK
- Validating a stack before deploy (
cdk synth, cdk-nag)
- Confirming AWS service capabilities / regional availability before coding
Verify AWS facts first
Do not answer AWS service questions from memory — APIs, runtimes, limits, and
regional availability change. Use AWS docs MCP tools when available
(mcp__aws-mcp__* / mcp__*awsdocs*__*). For CDK construct lookups and
best-practice patterns, AWS Labs ships awslabs.aws-iac-mcp-server (covers CDK +
CloudFormation; the older awslabs.cdk-mcp-server is deprecated):
claude mcp add aws-iac uvx awslabs.aws-iac-mcp-server@latest
Verify before implementing: new service features, region availability, API
params, service limits/quotas, security best practices.
Core principles
Resource naming — let CDK generate names
CRITICAL: do NOT set optional resource names (e.g. functionName, tableName).
Auto-generated names enable reusable patterns, parallel deployments, and stack
isolation without collisions.
// BAD — explicit name blocks reuse / parallel deploys
new lambda.Function(this, 'MyFunction', { functionName: 'my-lambda', /* ... */ });
// GOOD — CDK generates StackName-MyFunctionXXXXXX
new lambda.Function(this, 'MyFunction', { /* ... */ });
For dev/staging/prod isolation, use separate AWS accounts (Security Pillar), not
name prefixes in one account.
Lambda constructs (auto-bundle)
- TypeScript/JS:
NodejsFunction from aws-cdk-lib/aws-lambda-nodejs —
{ entry: 'lambda/handler.ts', handler: 'handler' }. Handles bundling +
transpilation.
- Python:
PythonFunction from @aws-cdk/aws-lambda-python-alpha —
{ entry: 'lambda', index: 'handler.py', handler: 'handler' }. Handles
dependency packaging.
Pre-deployment validation (multi-layer)
- cdk-nag at synth time (required). Install and wire via Aspects:
npm install --save-dev cdk-nag
import { Aspects } from 'aws-cdk-lib';
import { AwsSolutionsChecks } from 'cdk-nag';
Aspects.of(app).add(new AwsSolutionsChecks());
Available in all CDK languages. Suppress legitimate findings with a documented
reason via NagSuppressions.addResourceSuppressions(resource, [{ id, reason }]).
- Build + tests:
npm run build (or lang equivalent), then npm test /
pytest / mvn test.
- Synth check:
cdk synth (runs cdk-nag automatically through Aspects).
The source repo also ships a scripts/validate-stack.sh meta-check
(language detection, template size / resource-count analysis, synth success).
Workflow
Design → verify AWS services (MCP) → implement constructs → validate (above) →
cdk synth → review generated CloudFormation → cdk deploy → confirm resources.
Stack organization: nested stacks for complex apps, logical construct boundaries,
export cross-stack values, use CDK context for per-environment config. Test by
unit-testing constructs and snapshot-testing synthesized templates.
Gotchas
cdk deploy hits the live account — confirm identity first:
aws sts get-caller-identity --query Account --output text.
- If
.github/workflows/ exists, make those CI checks pass before committing.
Source helper files (not copied here)
plugins/aws-iac/skills/aws-cdk-development/references/cdk-patterns.md —
patterns, anti-patterns, security/cost/perf guidance.
plugins/aws-iac/skills/aws-cdk-development/scripts/validate-stack.sh —
pre-deploy validation script.
1---2name: aws-cdk3description: "Use when building AWS infrastructure as code with the Cloud Development Kit — creating or refactoring CDK stacks/constructs, defining Lambda in CDK, running cdk synth/cdk deploy, or when the user mentions CDK, CloudFormation, IaC, cdk-nag, NodejsFunction, or programmatic AWS provisioning in TypeScript/Python."4version: 1.0.05license: MIT6tags: [aws, cdk, cloudformation, iac, infrastructure, devops, lambda, typescript, cdk-nag, deployment]7source: https://github.com/zxkane/aws-skills8derived_from: awesomeclaude9prerequisites:10 commands: [cdk, npm, aws]11metadata:12 source: https://skillmd.com/skills/aashutosh396/aws-cdk13---1415# AWS CDK Development1617Guidance for building AWS infrastructure with the Cloud Development Kit (CDK) in18TypeScript or Python. Pairs well with AWS MCP servers for fetching current AWS19facts beyond the knowledge cutoff.2021## When to use2223- Creating or refactoring CDK stacks / constructs24- Implementing Lambda functions inside CDK25- Validating a stack before deploy (`cdk synth`, cdk-nag)26- Confirming AWS service capabilities / regional availability before coding2728## Verify AWS facts first2930Do not answer AWS service questions from memory — APIs, runtimes, limits, and31regional availability change. Use AWS docs MCP tools when available32(`mcp__aws-mcp__*` / `mcp__*awsdocs*__*`). For CDK construct lookups and33best-practice patterns, AWS Labs ships `awslabs.aws-iac-mcp-server` (covers CDK +34CloudFormation; the older `awslabs.cdk-mcp-server` is deprecated):3536```bash37claude mcp add aws-iac uvx awslabs.aws-iac-mcp-server@latest38```3940Verify before implementing: new service features, region availability, API41params, service limits/quotas, security best practices.4243## Core principles4445### Resource naming — let CDK generate names4647CRITICAL: do NOT set optional resource names (e.g. `functionName`, `tableName`).48Auto-generated names enable reusable patterns, parallel deployments, and stack49isolation without collisions.5051```typescript52// BAD — explicit name blocks reuse / parallel deploys53new lambda.Function(this, 'MyFunction', { functionName: 'my-lambda', /* ... */ });5455// GOOD — CDK generates StackName-MyFunctionXXXXXX56new lambda.Function(this, 'MyFunction', { /* ... */ });57```5859For dev/staging/prod isolation, use separate AWS accounts (Security Pillar), not60name prefixes in one account.6162### Lambda constructs (auto-bundle)6364- TypeScript/JS: `NodejsFunction` from `aws-cdk-lib/aws-lambda-nodejs` —65 `{ entry: 'lambda/handler.ts', handler: 'handler' }`. Handles bundling +66 transpilation.67- Python: `PythonFunction` from `@aws-cdk/aws-lambda-python-alpha` —68 `{ entry: 'lambda', index: 'handler.py', handler: 'handler' }`. Handles69 dependency packaging.7071## Pre-deployment validation (multi-layer)72731. **cdk-nag at synth time** (required). Install and wire via Aspects:74 ```bash75 npm install --save-dev cdk-nag76 ```77 ```typescript78 import { Aspects } from 'aws-cdk-lib';79 import { AwsSolutionsChecks } from 'cdk-nag';80 Aspects.of(app).add(new AwsSolutionsChecks());81 ```82 Available in all CDK languages. Suppress legitimate findings with a documented83 reason via `NagSuppressions.addResourceSuppressions(resource, [{ id, reason }])`.842. **Build + tests**: `npm run build` (or lang equivalent), then `npm test` /85 `pytest` / `mvn test`.863. **Synth check**: `cdk synth` (runs cdk-nag automatically through Aspects).87 The source repo also ships a `scripts/validate-stack.sh` meta-check88 (language detection, template size / resource-count analysis, synth success).8990## Workflow9192Design → verify AWS services (MCP) → implement constructs → validate (above) →93`cdk synth` → review generated CloudFormation → `cdk deploy` → confirm resources.9495Stack organization: nested stacks for complex apps, logical construct boundaries,96export cross-stack values, use CDK context for per-environment config. Test by97unit-testing constructs and snapshot-testing synthesized templates.9899## Gotchas100101- `cdk deploy` hits the live account — confirm identity first:102 `aws sts get-caller-identity --query Account --output text`.103- If `.github/workflows/` exists, make those CI checks pass before committing.104105## Source helper files (not copied here)106107- `plugins/aws-iac/skills/aws-cdk-development/references/cdk-patterns.md` —108 patterns, anti-patterns, security/cost/perf guidance.109- `plugins/aws-iac/skills/aws-cdk-development/scripts/validate-stack.sh` —110 pre-deploy validation script.