Skip to content

tysoncung/awesome-cdk-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Awesome CDK TypeScript Awesome

πŸš€ A curated list of awesome AWS CDK TypeScript resources, libraries, tools, and patterns

AWS CDK Logo TypeScript Logo

Contents β€’ Learning β€’ Constructs β€’ Patterns β€’ Tools β€’ Contributing


Contents


Learning Resources

Official Resources

Tutorials & Workshops

Videos & Courses

Books & Blogs


Construct Libraries

Official AWS Constructs

Community L3 Constructs

High-Level Patterns

Serverless

Containers & Kubernetes

Data & Analytics

Security & Compliance


Patterns & Examples

Application Patterns

Serverless Applications

Web Applications

Infrastructure Patterns

Networking

CI/CD

Multi-Account Patterns


Tools & Utilities

Development Tools

Testing Tools

Validation & Linting

Cost Management


Project Templates

Starter Templates

Organization Templates


TypeScript Specific

Type Safety Patterns

// Type-safe environment configuration
interface EnvironmentConfig {
  account: string;
  region: string;
  vpc: {
    cidr: string;
    maxAzs: number;
  };
}

class TypeSafeStack extends Stack {
  constructor(scope: Construct, id: string, config: EnvironmentConfig) {
    super(scope, id, {
      env: {
        account: config.account,
        region: config.region,
      }
    });
    // Use strongly typed config
  }
}

Generic Constructs

// Reusable generic construct
export class RestApi<T extends Record<string, any>> extends Construct {
  public readonly api: IRestApi;

  constructor(scope: Construct, id: string, props: RestApiProps<T>) {
    super(scope, id);
    // Implementation with type safety
  }
}

Advanced Patterns

TypeScript Configuration

// Recommended tsconfig.json for CDK projects
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "commonjs",
    "lib": ["ES2020"],
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "declaration": true,
    "declarationMap": true,
    "inlineSourceMap": true,
    "experimentalDecorators": true,
    "strictPropertyInitialization": false,
    "typeRoots": ["./node_modules/@types"]
  },
  "exclude": ["cdk.out", "node_modules"]
}

Real-World Projects

Open Source Applications

Company Case Studies

  • πŸ“‹ Liberty Mutual - Large-scale CDK adoption
  • πŸ“‹ Convoy - Migration to CDK
  • πŸ“‹ Stedi - Serverless APIs
  • πŸ“‹ Carsales - CDK adoption journey
  • πŸ“‹ RENGA - Startup CDK usage

Best Practices

Project Structure

my-cdk-app/
β”œβ”€β”€ bin/              # CDK app entry points
β”œβ”€β”€ lib/              # Stack definitions
β”‚   β”œβ”€β”€ constructs/   # Custom constructs
β”‚   β”œβ”€β”€ stacks/       # Stack classes
β”‚   └── shared/       # Shared utilities
β”œβ”€β”€ test/             # Unit tests
β”œβ”€β”€ scripts/          # Helper scripts
β”œβ”€β”€ config/           # Environment configs
└── docs/             # Documentation

Stack Organization

// Organize stacks by lifecycle and dependencies
export class NetworkStack extends Stack { }
export class DataStack extends Stack { }
export class ComputeStack extends Stack { }
export class MonitoringStack extends Stack { }

Testing Strategy

  • βœ… Unit Tests - Test construct properties
  • βœ… Snapshot Tests - Catch unintended changes
  • βœ… Fine-Grained Assertions - Test specific resources
  • βœ… Integration Tests - Test deployed resources
  • βœ… Compliance Tests - Security and compliance checks

Security Best Practices

  • πŸ”’ Use least-privilege IAM policies
  • πŸ”’ Enable encryption at rest and in transit
  • πŸ”’ Use Secrets Manager for sensitive data
  • πŸ”’ Enable AWS CloudTrail logging
  • πŸ”’ Implement resource tagging strategies
  • πŸ”’ Use CDK Nag for compliance checking

Cost Optimization

  • πŸ’‘ Use cost allocation tags
  • πŸ’‘ Implement auto-scaling policies
  • πŸ’‘ Use Spot instances where appropriate
  • πŸ’‘ Set up billing alarms
  • πŸ’‘ Regular cost reviews with Infracost

Community & Support

Community Resources

Events & Meetups

Notable Contributors


Migration & Upgrade Guides

Version Migrations

CloudFormation to CDK

Terraform to CDK


Performance & Optimization

Build Performance

Runtime Performance

Cost Optimization Patterns


Troubleshooting & Debugging

Common Issues

Deployment Failures

// Issue: Stack too large (>50MB)
// Solution: Use asset bundling or split into multiple stacks

// Issue: Resource limit exceeded
// Solution: Request service quota increase

// Issue: Circular dependencies
// Solution: Use exportValue() and Fn.importValue()
const vpcId = vpc.exportValue('VpcId');
const importedVpc = ec2.Vpc.fromVpcAttributes(this, 'ImportedVpc', {
  vpcId: Fn.importValue('VpcId')
});

TypeScript Errors

// Issue: Type inference fails
// Solution: Explicit type annotations

const bucket: s3.IBucket = new s3.Bucket(this, 'MyBucket', {
  bucketName: 'my-bucket'
});

// Issue: Module not found
// Solution: Check node_modules and tsconfig paths

Debugging Tools

Log Analysis

// Enable detailed CloudFormation logging
import { CfnOutput } from 'aws-cdk-lib';

new CfnOutput(this, 'StackName', {
  value: this.stackName,
  description: 'Current stack name for debugging'
});

// Enable CDK verbose output
// cdk deploy --verbose
// cdk diff --verbose

Plugins & Extensions

IDE Extensions

CLI Plugins

Build Tool Integrations


Advanced Topics

Multi-Region Deployments

// Deploy to multiple regions
const usEast1App = new App();
new MyStack(usEast1App, 'MyStack-us-east-1', {
  env: { region: 'us-east-1', account: '123456789012' }
});

const euWest1App = new App();
new MyStack(euWest1App, 'MyStack-eu-west-1', {
  env: { region: 'eu-west-1', account: '123456789012' }
});

Custom Resource Providers

import { CustomResource, CustomResourceProvider } from 'aws-cdk-lib';

// Create custom resource for unsupported AWS features
const provider = CustomResourceProvider.getOrCreateProvider(this, 'Custom::MyResource', {
  codeDirectory: './custom-resources',
  runtime: Runtime.NODEJS_18_X,
  policyStatements: [/* IAM permissions */]
});

new CustomResource(this, 'MyCustomResource', {
  serviceToken: provider.serviceToken,
  properties: {
    key: 'value'
  }
});

CDK Aspects

import { IAspect, IConstruct, Tags } from 'aws-cdk-lib';

// Implement cross-cutting concerns
class TaggingAspect implements IAspect {
  visit(node: IConstruct): void {
    if (node instanceof Bucket) {
      Tags.of(node).add('Environment', 'Production');
    }
  }
}

Aspects.of(app).add(new TaggingAspect());

Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Criteria for Inclusion

  • Must be TypeScript-specific or have excellent TypeScript support
  • Active maintenance (commits within last 6 months)
  • Clear documentation
  • Adds value to the CDK TypeScript ecosystem
Built with ❀️ by the CDK TypeScript community