AWS Reference Architectures implemented with CDK - Collection of cloud architecture patterns and best practices with practical examples using AWS CDK
This repository provides reference architectures for AWS implemented using AWS Cloud Development Kit (CDK). Each architecture pattern includes detailed documentation, architecture diagrams, and CDK implementation in TypeScript/Python.
- Node.js 20.x or later
- AWS CLI configured with appropriate credentials
- AWS CDK CLI installed (
npm install -g aws-cdk)
This reference architecture requires creating an AWS profile named project-env (where project and env are passed as CDK command arguments) before running CDK commands.
Using AWS IAM Identity Center:
# ~/.aws/config
[sso-session my-session]
sso_start_url = https://d-956745f993.awsapps.com/start/
sso_region = ap-northeast-1
sso_registration_scopes = sso:account:access
[profile project-env]
sso_session = my-session
sso_account_id = 123456789012
sso_role_name = YourRoleName
region = ap-northeast-1
output = jsonUsing IAM User with MFA (Assume Role):
# ~/.aws/config
[profile project-env]
source_profile = project-env-accesskey
role_arn = arn:aws:iam::123456789012:role/YourRoleName
mfa_serial = arn:aws:iam::123456789012:mfa/yourdevicename
region = ap-northeast-1
output = json# ~/.aws/credentials
[project-env-accesskey]
aws_access_key_id = xxxxxxxxxx
aws_secret_access_key = xxxxxxxxxxUsing IAM User with MFA (Direct Permissions):
# ~/.aws/config
[profile project-env]
source_profile = project-env-accesskey
mfa_serial = arn:aws:iam::123456789012:mfa/yourdevicename
region = ap-northeast-1
output = json# ~/.aws/credentials
[project-env-accesskey]
aws_access_key_id = xxxxxxxxxx
aws_secret_access_key = xxxxxxxxxxUsing Temporary Credentials:
# ~/.aws/config
[profile project-env]
aws_access_key_id = xxxxxxxxxx
aws_secret_access_key = xxxxxxxxxx
aws_session_token = xxxxxxxxxx- Clone the repository
git clone https://github.com/ishiharatma/aws-cdk-reference-architectures.git- Install dependencies
cd aws-cdk-reference-architectures/infrastructure/cdk
npm installaws-cdk-reference-architectures/
βββ docs/ # Documentation Root Folder
βββ scripts/ # Workspace Initialize Scripts
βββ templates/ # Workspace templates
βββ infrastructure/
β ββββ cdk/ # CDK project root folder
β βββ common # Common
β βββ workspaces # CDK Workspace
β βββ<pattern-name>
β βββ bin/ # CDK app entry point
β βββ lib/ #
β | βββ aspects/ # CDK Aspects
β | βββ constructs/ # Custom constructs
β | βββ stacks/ # CDK stacks
β | βββ stages/ # CDK stages
β | βββ types/ # Type definitions
| βββ src/ # Source files
| βββ parameters/ # Environment Parameters
| βββ test/ # Tests
β βββ compliance/ # Compliance Tests
β βββ integration/ # Integration Tests
β βββ helpers/ # Helper functions for tests
β βββ snapshot/ # Snapshot Tests
β βββ unit/ # Fine-grained assertions Tests
β βββ validation/ # Validation Tests
β
Each architecture pattern includes:
- Detailed documentation explaining the architecture
- Architecture diagrams (draw.io and exported images)
- CDK implementation with deployment instructions
- Cost considerations and operational guidelines
This project uses a workspace structure based on npm workspaces.
Initialize the workspace using the provided shell script:
./scripts/init-cdk.sh infrastructure/cdk-workspaces- Install dependencies for all workspaces
cd infrastructure/cdk-workspaces
npm install- Build all CDK apps
npm run build- Deploy a specific CDK app
npm run deploy -w workspaces/serverless --project=example --env=devThe deployment command uses npm workspaces with project and environment parameters to select the appropriate AWS profile (e.g., example-dev for project=example and env=dev).
Each CDK app in the workspace follows this structure:
workspaces/<pattern-name>/
βββ bin/ # CDK app entry point
| βββ <pattern-name>.ts #
βββ lib/ #
| βββ aspects/ # CDK Aspects
| βββ constructs/ # Custom constructs
| βββ stacks/ # CDK stacks
| | βββ <pattern-name>-stack.ts
| βββ stages/ # CDK stages
| | βββ <pattern-name>-stage.ts
| βββ types/ # Type definitions
βββ src/ # Source files
βββ parameters/ # Environment Parameters
βββ test/ # Tests
βββ cdk.json # CDK configuration
βββ package.json # Dependencies
To add a new workspace to the CDK project, use the provided script:
./scripts/add-usecase.sh s3-basicsThis will create a new CDK app with the standard structure and configurations.
We welcome contributions! Please see our Contributing Guide for details.
This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.
Please file an issue if you have any questions, feedback, or feature requests.
