New to Claude Skills? Learn how to install them →

aws on GitHub

AWS CDK

OfficialFree

Streamline AWS infrastructure management with CDK.

by aws2.3k stars on aws/agent-toolkit-for-aws
2 views
Updated Aug 10, 2026
Get this skill

Free · Opens the source repo

What AWS CDK does

The AWS CDK skill provides developers and designers with a comprehensive toolkit for authoring, deploying, and troubleshooting AWS infrastructure using the Cloud Development Kit (CDK) in TypeScript or Python. This skill is particularly beneficial for those who need to implement best practices in stack architecture and construct patterns, ensuring a smoother workflow when working with AWS resources. It covers a range of essential tasks, from bootstrapping environments to running deployment commands and addressing common errors encountered with CDK and CloudFormation.

With this skill, users can efficiently manage their AWS infrastructure by utilizing straightforward commands for various workflows. For instance, bootstrapping a new project is as simple as executing cdk bootstrap aws://$ACCOUNT/$REGION, while deploying changes involves a clear sequence of cdk synth, cdk diff, and cdk deploy. Additionally, the skill includes guidance on compliance checks using cdk-nag and drift detection, which are crucial for maintaining the integrity of deployed resources.

The AWS CDK skill is designed for developers and DevOps engineers who are already familiar with AWS services and seek to leverage the power of CDK for infrastructure as code. It is particularly useful in environments where rapid iteration and compliance are necessary. The skill also addresses common pitfalls and troubleshooting techniques, providing users with the knowledge to resolve issues effectively and maintain a robust deployment pipeline.

However, this skill is not intended for users who prefer raw CloudFormation YAML/JSON, SAM, Terraform, or Pulumi. It focuses specifically on CDK workflows and may not provide the necessary support for CI/CD processes outside of CDK Pipelines or for those requiring more extensive infrastructure management capabilities beyond what CDK offers.

When to use it

Use this skill when developing and deploying AWS infrastructure using the CDK, especially for TypeScript or Python projects.

When not to use it

This skill is not suitable for users working exclusively with raw CloudFormation templates, SAM, Terraform, or those needing CI/CD solutions beyond CDK Pipelines.

What you can build with it

Bootstrapping a New Project

Quickly bootstrap a new AWS CDK project using the command `cdk bootstrap aws://$ACCOUNT/$REGION`.

Deploying Changes to AWS

Easily deploy changes to your AWS infrastructure by following the sequence: `cdk synth`, `cdk diff`, and `cdk deploy`.

Detecting Resource Drift

Use the command `cdk drift $STACK` to check for any discrepancies between your deployed resources and the CDK stack.

How to install AWS CDK

View source

1. Install with the skills CLI

npx skills add aws/agent-toolkit-for-aws/aws-cdk --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by aws

AWS CDK

Overview

Domain expertise for CDK construct authoring, deployment workflows, compliance, drift, importing resources, safe refactoring, and troubleshooting CDK CLI / CloudFormation errors.

When NOT to use: Raw CloudFormation YAML/JSON. SAM. Terraform/Pulumi. CI/CD beyond CDK Pipelines. Use builtin knowledge or specialized skills for these.

Critical Warnings

Deadly embrace: Removing a cross-stack reference deadlocks deployment (Export ... cannot be deleted as it is in use by ...). Preferred fix: weaken the reference first — CrossStackReferences.of($RESOURCE).produce(ReferenceStrength.BOTH) then WEAK, then remove (three deploys). Legacy fallback: two-deploy this.exportValue() recipe. See troubleshooting-deployment.

Construct ID changes cause replacement: Renaming/moving a construct changes its logical ID → CloudFormation replaces the resource (data loss for stateful resources). Always cdk diff before deploy. See refactor-and-prevent-replacement.

UPDATE_ROLLBACK_FAILED: Stack is stuck. Fix with cdk rollback $STACK or cdk rollback $STACK --orphan <LogicalId>. See troubleshooting-deployment.

Non-empty S3 buckets persist after destroy: You MUST set both removalPolicy: DESTROY and autoDeleteObjects: true. Versioned buckets are worse — delete markers persist even after apparent deletion.

Common Workflows

TaskQuick CommandDetails
Bootstrapcdk bootstrap aws://$ACCOUNT/$REGIONbootstrap-and-project-setup
New TS projectcdk init app --language typescript — use tsx, eslint-plugin-awscdkbootstrap-and-project-setup
New Python projectcdk init app --language python — pin deps, use virtualenvbootstrap-and-project-setup
Deploycdk synth --strictcdk diffcdk deployAlways diff before deploy to prod
cdk-nagAspects.of(app).add(new AwsSolutionsChecks())compliance-and-drift
Driftcdk drift $STACK (use --fail in CI)compliance-and-drift
Import resourcecdk import (interactive or --resource-mapping for CI), cdk deploy --import-existing-resourcesimport-and-migrate
Refactor safelycdk refactor --unstable=refactor — no property changes in same deployrefactor-and-prevent-replacement

Troubleshooting

ErrorCause → Fix
DeployFailed / DeploymentErrorCDK error isn't the root cause. cdk deploy $STACK --verbose, then cdk --unstable=diagnose diagnose $STACK (CLI ≥ 2.1120.0); else aws cloudformation describe-events --stack-name $STACK --filters FailedEvents=true — the first _FAILED event is the cause. Details
NoCredentials / ExpiredToken / AssumeRoleFailedaws sts get-caller-identity + cdk doctor. Expired SSO, missing env, missing sts:AssumeRole. Details
Asset errors (CannotFindAsset, FailedToBundleAsset, AssetBuildFailed, AssetPublishFailed)Path wrong, Docker not running, or bootstrap bucket perms. Use path.join(__dirname, ...). Details
AppRequiredAdd "app": "npx tsx bin/my-app.ts" to cdk.json. Details
AnnotationErrorsFix the underlying issue; suppress with NagSuppressions only as last resort. Details
ConcurrentReadLock / ConcurrentWriteLockrm -rf cdk.out then re-run. Parallel CI: --output ./cdk.out.$BUILD_ID. Details
BootstrapVersionValidationRe-bootstrap. Match --qualifier everywhere. Details
DependencyCycleExtract shared resource into third stack or use SSM for late-binding. Details
UnresolvedAccountSet explicit env: { account, region } on stack. Commit cdk.context.json. Details
NoStacksMatchedCDK uses logical ID (2nd constructor arg), not CFN name. cdk list to find IDs. Details
Cannot find module (synth time)Run npx tsc --noEmit, check cdk.json app path matches tsconfig.json outDir, delete stale .js files. Python: activate venv. Details
V1 import paths / duplicate aws-cdk-libV1 @aws-cdk/* imports, wrong Construct import, duplicate lib copies in monorepos. Details
Lambda Cannot find module (runtime)Wrong handler value, missing SDK v3 migration, Python deps not bundled. Details
API Gateway multi-stage conflictsSet deploy: false on RestApi, create Deployment and Stage explicitly. Details

Construct Patterns

Prefer L2. Use L1 with Mixins/Facades when L2 lacks a property. Escape hatches: node.defaultChildaddPropertyOverride. See construct-patterns.

Additional Resources

  • Search AWS documentation for "CDK Developer Guide", "CDK API Reference" and "CDK Pipelines" respectively

Security Considerations

  • OIDC for CI/CD credentials (no static keys)
  • --custom-permissions-boundary on bootstrap
  • grant*() for inter-resource IAM
  • cdk-nag + --strict in CI
  • Stateful resources in own stack with terminationProtection: true
  • Commit cdk.context.json

Frequently asked questions about AWS CDK

Similar skills