aws-cdk
This skill provides AWS CDK TypeScript patterns for defining and deploying infrastructure as code.
Community author
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
- License
- MIT (permissive)
- Pin
- fe73fb3pinned Oct 9, 2026
- Context cost
- about 2,200 tokenswhen the skill loads
- GitHub stars
- 356on giuseppe-trisciuoglio/developer-kit
- Scripts
- None found
What it does
“Provides AWS CDK TypeScript patterns for defining, validating, and deploying AWS infrastructure as code. Use when creating CDK apps, stacks, and reusable constructs, modeling serverless or VPC-based architectures, applying IAM and encryption defaults, or testing and reviewing `cdk synth`, `cdk diff`, and `cdk deploy` changes. Triggers include "aws cdk typescript", "create cdk app", "cdk stack", "cdk construct", "cdk deploy", and "cdk test".”
Generated summary from the skill's own text
This skill provides AWS CDK TypeScript patterns for defining and deploying infrastructure as code. It covers constructing stacks and reusable components, choosing between construct levels, and validating changes through synthesis, testing, diffs, and deployment. Use it when building serverless applications, VPC architectures, or multi-stack applications with IAM and encryption defaults.
When to use it
- Creating or refactoring CDK apps and custom TypeScript constructs
- Building serverless or VPC-focused AWS infrastructure
- Validating infrastructure changes before deployment with cdk synth and cdk diff
- Designing multi-stack applications with cross-stack references and environments
When not to
- Deploying infrastructure without code review or testing workflows
- Managing existing CloudFormation templates not created as CDK
- Working with AWS resources not yet supported by CDK construct libraries
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add giuseppe-trisciuoglio/developer-kit --skill aws-cdkInstalls from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install giuseppe-trisciuoglio/developer-kit aws-cdk@fe73fb33a09ee6562eeec7415a3f9a3bcf795177Installs the commit we checked (fe73fb3).
Copy by hand
Download the folder at fe73fb3 and put it in .claude/skills/aws-cdk for Claude Code and in .agents/skills/aws-cdk for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "aws-cdk" by giuseppe-trisciuoglio. Source, pinned to commit fe73fb33a09ee6562eeec7415a3f9a3bcf795177: https://github.com/giuseppe-trisciuoglio/developer-kit/tree/fe73fb33a09ee6562eeec7415a3f9a3bcf795177/plugins/developer-kit-typescript/skills/aws-cdk 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/aws-cdk/ for Claude Code and .agents/skills/aws-cdk/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/giuseppe-trisciuoglio/aws-cdk
SKILL.md at the pin
---
name: aws-cdk
description: Provides AWS CDK TypeScript patterns for defining, validating, and deploying AWS infrastructure as code. Use when creating CDK apps, stacks, and reusable constructs, modeling serverless or VPC-based architectures, applying IAM and encryption defaults, or testing and reviewing `cdk synth`, `cdk diff`, and `cdk deploy` changes. Triggers include "aws cdk typescript", "create cdk app", "cdk stack", "cdk construct", "cdk deploy", and "cdk test".
allowed-tools: Read, Write, Edit, Bash, Grep, Glob
---
# AWS CDK TypeScript
## Overview
Use this skill to build AWS infrastructure in TypeScript with reusable constructs, safe defaults, and a validation-first delivery loop.
## When to Use
Use this skill when:
- Creating or refactoring a CDK app, stack, or reusable construct in TypeScript
- Choosing between L1, L2, and L3 constructs
- Building serverless, networking, or security-focused AWS infrastructure
- Wiring multi-stack applications and environment-aware deployments
- Validating infrastructure changes with `cdk synth`, tests, `cdk diff`, and `cdk deploy`
## Instructions
### 1. Project Initialization
```bash
# Create a new CDK app
npx cdk init app --language typescript
# Project structure
my-cdk-app/
├── bin/
│ └── my-cdk-app.ts # App entry point (instantiates stacks)
├── lib/
│ └── my-cdk-app-stack.ts # Stack definition
├── test/
│ └── my-cdk-app.test.ts # Tests
├── cdk.json # CDK configuration
├── tsconfig.json
└── package.json
```
### 2. Core Architecture
```typescript
import { App, Stack, StackProps, CfnOutput, RemovalPolicy } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as s3 from 'aws-cdk-lib/aws-s3';
// Define a reusable stack
class StorageStack extends Stack {
public readonly bucketArn: string;
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const bucket = new s3.Bucket(this, 'DataBucket', {
versioned: true,
encryption: s3.BucketEncryption.S3_MANAGED,
removalPolicy: RemovalPolicy.RETAIN,
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
});
this.bucketArn = bucket.bucketArn;
new CfnOutput(this, 'BucketName', { value: bucket.bucketName });
}
}
// App entry point
const app = new App();
new StorageStack(app, 'DevStorage', {
env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'us-east-1' },
tags: { Environment: 'dev' },
});
new StorageStack(app, 'ProdStorage', {
env: { account: '123456789012', region: 'eu-west-1' },
tags: { Environment: 'prod' },
terminationProtection: true,
});
app.synth();
```
### 3. Construct Levels
| Level | Description | Use When |
|-------|-------------|----------|
| **L1** (`Cfn*`) | Direct CloudFormation mapping, full control | Need properties not exposed by L2 |
| **L2** | Curated with sensible defaults and helper methods | Standard resource provisioning (recommended) |
| **L3** (Patterns) | Multi-resource architectures | Common patterns like `LambdaRestApi` |
```typescript
// L1 — Raw CloudFormation
new s3.CfnBucket(this, 'L1Bucket', { bucketName: 'my-l1-bucket' });
// L2 — Sensible defaults + grant helpers
const bucket = new s3.Bucket(this, 'L2Bucket', { versioned: true });
bucket.grantRead(myLambda);
// L3 — Multi-resource pattern
new apigateway.LambdaRestApi(this, 'Api', { handler: myLambda });
```
### 4. CDK Lifecycle Commands
```bash
cdk synth # Synthesize CloudFormation template
cdk diff # Compare deployed vs local changes
cdk deploy # Deploy stack(s) to AWS
cdk deploy --all # Deploy all stacks
cdk destroy # Tear down stack(s)
cdk ls # List all stacks in the app
cdk doctor # Check environment setup
```
### 5. Recommended Delivery Loop
1. **Model the stack**
- Start with L2 constructs and extract repeated logic into custom constructs.
2. **Run `cdk synth`**
- Checkpoint: synthesis succeeds with no missing imports, invalid props, missing context, or unresolved references.
- If it fails: fix the construct configuration or context values, then rerun `cdk synth`.
3. **Run infrastructure tests**
- Checkpoint: assertions cover IAM scope, stateful resources, and critical outputs.
- If tests fail: update the stack or test expectations, then rerun the test suite.
4. **Run `cdk diff`**
- Checkpoint: review IAM broadening, resource replacement, export changes, and deletes on stateful resources.
- If the diff is risky: adjust names, dependencies, or `RemovalPolicy`, then rerun `cdk diff`.
5. **Run `cdk deploy`**
- Checkpoint: the stack reaches `CREATE_COMPLETE` or `UPDATE_COMPLETE`.
- If deploy fails: inspect CloudFormation events, fix quotas, permissions, export conflicts, or bootstrap issues, then retry `cdk deploy`.
6. **Verify runtime outcomes**
- Confirm stack outputs, endpoints, alarms, and integrations behave as expected before moving on.
### 6. Cross-Stack References
```typescript
// Stack A exports a value
class NetworkStack extends Stack {
public readonly vpc: ec2.Vpc;
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
this.vpc = new ec2.Vpc(this, 'Vpc', { maxAzs: 2 });
}
}
// Stack B imports it via props
interface AppStackProps extends StackProps {
vpc: ec2.Vpc;
}
class AppStack extends Stack {
constructor(scope: Construct, id: string, props: AppStackProps) {
super(scope, id, props);
new lambda.Function(this, 'Fn', {
runtime: lambda.Runtime.NODEJS_20_X,
handler: 'index.handler',
code: lambda.Code.fromAsset('lambda'),
vpc: props.vpc,
});
}
}
// Wire them together
const network = new NetworkStack(app, 'Network');
new AppStack(app, 'App', { vpc: network.vpc });
```
## Examples
### Example 1: Serverless API
```typescript
import * as cdk from 'aws-cdk-lib';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
class ServerlessApiStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const table = new dynamodb.Table(this, 'Items', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
const fn = new lambda.Function(this, 'Handler', {
runtime: lambda.Runtime.NODEJS_20_X,
handler: 'index.handler',
code: lambda.Code.fromAsset('lambda'),
environment: { TABLE_NAME: table.tableName },
});
table.grantReadWriteData(fn);
new apigateway.LambdaRestApi(this, 'Api', { handler: fn });
}
}
```
### Example 2: CDK Assertion Test
```typescript
import { Template } from 'aws-cdk-lib/assertions';
import { App } from 'aws-cdk-lib';
import { ServerlessApiStack } from '../lib/serverless-api-stack';
test('creates DynamoDB table with PAY_PER_REQUEST', () => {
const app = new App();
const stack = new ServerlessApiStack(app, 'TestStack');
const template = Template.fromStack(stack);
template.hasResourceProperties('AWS::DynamoDB::Table', {
BillingMode: 'PAY_PER_REQUEST',
});
template.resourceCountIs('AWS::Lambda::Function', 1);
});
```
## Best Practices
1. **One concern per stack** — Separate network, compute, storage, and monitoring.
2. **Prefer L2 constructs** — Drop to `Cfn*` only when you need unsupported properties.
3. **Set explicit environments** — Pass `env` with account and region; avoid implicit production targets.
4. **Use grant helpers** — Prefer `.grant*()` over handwritten IAM where possible.
5. **Review the diff before deploy** — Treat IAM expansion, replacement, and deletes as mandatory checkpoints.
6. **Test infrastructure** — Cover critical resources with fine-grained assertions.
7. **Avoid hardcoded values** — Use context, parameters, or environment variables.
8. **Use the right `RemovalPolicy`** — `RETAIN` for production data, `DESTROY` only for disposable environments.
## Constraints and Warnings
- **CloudFormation limits** — Max 500 resources per stack; split large apps into multiple stacks
- **Synthesis is not deployment** — `cdk synth` only generates templates; `cdk deploy` applies changes
- **Cross-stack references** create CloudFormation exports; removing them requires careful ordering
- **Stateful resources** (RDS, DynamoDB, S3 with data) — Always set `removalPolicy: RETAIN` in production
- **Bootstrap required** — Run `cdk bootstrap` once per account/region before first deploy
- **Asset bundling** — Lambda code and Docker images are uploaded to the CDK bootstrap bucket
## References
Detailed implementation guides are available in the `references/` directory:
- [Core Concepts](references/core-concepts.md) — App lifecycle, stacks, constructs, environments, assets
- [Serverless Patterns](references/serverless-patterns.md) — Lambda, API Gateway, DynamoDB, S3 events, Step Functions
- [Networking & VPC](references/networking-vpc.md) — VPC design, subnets, NAT, security groups, VPC endpoints
- [Security Hardening](references/security-hardening.md) — IAM, KMS, Secrets Manager, WAF, compliance
- [Testing Strategies](references/testing-strategies.md) — Assertions, snapshots, integration tests, CDK Nag
From giuseppe-trisciuoglio/developer-kit at fe73fb3, shown as plain text under its license: MIT (permissive). The license text is in LICENSE.
View SKILL.md on GitHub at fe73fb3Files
- SKILL.md9.5 KB · c55115106edb
- references/
- core-concepts.md9.3 KB · c017f8fb7d65
- networking-vpc.md8.3 KB · 682f17c2fb80
- security-hardening.md9.1 KB · 468674e0e910
- serverless-patterns.md11 KB · 5caebf7c1312
- testing-strategies.md9.9 KB · 2bdcfea58322
6 files, 57 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at fe73fb3Related in Cloud and DevOps
hf-cloud-aws-context-discovery
This skill reads the user's local AWS configuration to discover their active profile, region, account ID, and caller identity before any AWS work begins.
by Hugging FaceOfficial publisher
Claude Code, Codex, Cursor +4 · about 830 tokens · pinned 6 days ago
hf-cloud-python-env-setup
Sets up an isolated Python environment for SageMaker and AWS work with the correct Python version (3.10, 3.11, or 3.12) and current boto3 and awscli.
by Hugging FaceOfficial publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 1.5K tokens · pinned 6 days ago
hf-cloud-sagemaker-deployment-planner
This skill helps users plan and execute deployments of machine learning models to Amazon SageMaker by gathering requirements, selecting appropriate deployment…
by Hugging FaceOfficial publisher
Claude Code, Codex, Cursor +4 · about 1.9K tokens · pinned 6 days ago
hf-cloud-sagemaker-iam-preflight
This skill validates or creates an AWS IAM execution role before deploying SageMaker endpoints, training jobs, or models.
by Hugging FaceOfficial publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 1.6K tokens · pinned 6 days ago
hf-cloud-serving-image-selection
This skill helps select the correct SageMaker serving container image for model deployments and retrieves its current URI from AWS's Deep Learning Containers…
by Hugging FaceOfficial publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 4.3K tokens · pinned 6 days ago
agent-advisor
Guides startups through a phased decision process to choose an AWS runtime for AI agents (AgentCore, ECS, EKS, Lambda, or Lambda MicroVMs), plan migrations of…
by Amazon (AWS)Official publisher
Contains scripts
Claude Code · about 4.6K tokens · pinned 6 days ago