CDK Design Patterns

Outlines recommended design patterns for AWS CDK development. Design patterns are reusable solutions to common problems in software development. Following these patterns will ensure consistency, maintainability, and scalability across the codebase. The patterns described here are particularly relevant for AWS CDK development.

TypeScript
CDK

@cremich

Author

Submitted on April 22, 2025
# CDK Design Patterns Rules

## Factories for common constructs

- Create factories for common L3 constructs when the L3 construct consists of multiple L1 or L2 constructs designed to work together or when specific configurations or defaults must be enforced.
- Factories must encapsulate best practices and default configurations.
- Always use factories when provided instead of directly instantiating resources to ensure consistent configuration and simplify changes.

## CDK Aspects

- Use CDK aspects to modify, validate, or enforce standards across all constructs within a given scope.
- Use CDK aspects to apply consistent tags across all resources
- Use CDK aspects to apply removal policies for ephemeral environments
CDK Design Patterns - Project Rule for Amazon Q Developer