Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
aws avatar

Aws Cdk

  • 4.6k installs
  • 2.2k repo stars
  • Updated August 4, 2026
  • aws/agent-toolkit-for-aws

aws-cdk is an agent skill for authoring, deploying, and troubleshooting AWS CDK stacks with TypeScript or Python including diff, drift, import, and safe refactor patterns.

About

aws-cdk is a domain skill for authoring and operating AWS CDK infrastructure with TypeScript or Python constructs, covering bootstrap, synth, diff, deploy, compliance, drift detection, resource import, and safe refactoring. Critical warnings document deadly embrace cross-stack export deadlocks requiring weakened references across three deploys, construct ID renames that trigger CloudFormation replacement, UPDATE_ROLLBACK_FAILED recovery via cdk rollback, and non-empty S3 buckets needing removalPolicy DESTROY plus autoDeleteObjects true. Workflows map bootstrap, cdk init, cdk-nag AwsSolutionsChecks, cdk drift with optional --fail in CI, cdk import, and cdk refactor without property changes in the same deploy. Troubleshooting ties DeployFailed to verbose deploy and diagnose commands, credential errors to aws sts get-caller-identity, asset bundling failures to Docker and path issues, and dependency cycles to shared stack extraction or SSM late binding. Construct guidance prefers L2 constructs with escape hatches via node.defaultChild addPropertyOverride. Security recommendations include OIDC CI credentials, permissions boundaries on bootstrap, grant helpers for IAM, cdk-nag with --st.

  • Covers CDK bootstrap, synth, diff, deploy, drift, import, and refactor workflows.
  • Documents deadly embrace cross-stack reference removal across three deploy steps.
  • Construct ID changes trigger replacement; always cdk diff before production deploy.
  • Troubleshooting tables for credentials, assets, dependency cycles, and rollback failures.
  • Recommends cdk-nag AwsSolutionsChecks, OIDC CI auth, and terminationProtection on stateful stacks.

Aws Cdk by the numbers

  • 4,600 all-time installs (skills.sh)
  • +516 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #118 of 1,039 Cloud & Infrastructure skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
At a glance

aws-cdk capabilities & compatibility

Capabilities
cdk project bootstrap and typescript or python i · synth, diff, deploy, drift, and import workflow · cross stack reference and refactor safety proced · troubleshooting maps for credentials, assets, an · construct l2 preference with escape hatch overri
Works with
aws · docker · terraform · kubernetes
Use cases
devops · ci cd · api development
From the docs

What aws-cdk says it does

Always diff before deploy to prod
SKILL.md
npx skills add https://github.com/aws/agent-toolkit-for-aws --skill aws-cdk

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs4.6k
repo stars2.2k
Security audit3 / 3 scanners passed
Last updatedAugust 4, 2026
Repositoryaws/agent-toolkit-for-aws

How do I write or fix AWS CDK stacks without accidental resource replacement, cross-stack deadlocks, or stuck CloudFormation rollbacks?

Author, deploy, troubleshoot, and safely refactor AWS CDK stacks in TypeScript or Python with synth, diff, drift, and import workflows.

Who is it for?

Developers implementing AWS infrastructure as CDK who need construct patterns plus deployment troubleshooting guardrails.

Skip if: Skip for raw CloudFormation YAML, Terraform, Pulumi, or CI/CD pipelines beyond CDK Pipelines scope.

When should I use this skill?

User mentions CDK constructs, cdk deploy, cdk diff, bootstrap, CloudFormation errors, stack import, or CDK drift.

What you get

Bootstrapped CDK app with linted constructs, successful synth and diff, deployed stacks, and documented fixes for common CDK CLI failures.

  • CDK stack constructs
  • cdk.context.json
  • deployment troubleshooting notes

By the numbers

  • Bundles 9 reference guides under skills/core-skills/aws-cdk/references/
  • CDKToolkit bootstrap creates 4 IAM roles plus S3, ECR, and SSM resources
  • Supports TypeScript and Python project initialization via cdk init

Files

SKILL.mdMarkdownGitHub ↗

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

Related skills

How it compares

Use for CDK construct work; defer raw CloudFormation, SAM, Terraform, or broad CI/CD to other tooling.

FAQ

What causes deadly embrace in CDK?

Removing a cross-stack export while another stack still imports it deadlocks deployment; weaken references across three deploys first.

Why must I run cdk diff before prod deploy?

Renaming or moving constructs changes logical IDs and CloudFormation may replace stateful resources causing data loss.

How do I fix UPDATE_ROLLBACK_FAILED?

Use cdk rollback STACK or cdk rollback STACK --orphan LogicalId per the troubleshooting deployment reference.

Is Aws Cdk safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.