This library provides a comprehensive set of AWS CDK constructs that power the Fastish infrastructure platform. It implements a configuration-driven approach using Mustache templating to transform YAML configurations into type-safe Java objects during CDK synthesis. The library follows CDK Best Practices and AWS Well-Architected Framework principles.
Feature
Description
Reference
Reusable Constructs
Production-ready CDK constructs for common AWS patterns
AWS CDK Constructs
Template Processing
Mustache-based configuration templating
Mustache
Type Safety
YAML to Java POJO serialization via Jackson
Jackson YAML
Environment Support
Multi-environment configuration resolution
CDK Context
Add the dependency to your Maven pom.xml:
<dependency >
<groupId >io.tinstafl</groupId >
<artifactId >cdk-common</artifactId >
<version >1.0.0-SNAPSHOT</version >
</dependency >
Build from source:
git clone https://github.com/fast-ish/cdk-common.git
cd cdk-common
mvn clean install
The library provides constructs for the following AWS services:
Service
Construct
Reference
Lambda
Function, Layer, EventSourceMapping
AWS Lambda
EKS
Cluster, NodeGroup, Addon, HelmChart
Amazon EKS
Service
Construct
Reference
S3
Bucket, BucketPolicy, LifecycleRule
Amazon S3
EBS
Volume, Snapshot
Amazon EBS
Service
Construct
Reference
DynamoDB
Table, GlobalSecondaryIndex, Stream
Amazon DynamoDB
RDS
Instance, Cluster, ParameterGroup
Amazon RDS
The cdk-common library implements a four-stage build process during CDK synthesis:
CDK Context → Template Resolution → Mustache Processing → POJO Mapping
Stage 1: CDK Context Injection
Context variables from cdk.context.json are extracted and made available as template variables:
{
":account" : " 123456789012" ,
":region" : " us-west-2" ,
":environment" : " prototype" ,
":version" : " v1"
}
See: CDK Context
Stage 2: Template Resolution
Templates are loaded from the environment/version directory structure:
src/main/resources/
└── {environment}/
└── {version}/
├── conf.mustache
└── {component}/
└── *.mustache
Example: prototype/v1/conf.mustache
Stage 3: Mustache Processing
Mustache templating engine processes variables:
# Input template
vpc :
name : {{hosted:id}}-vpc
cidr : 10.0.0.0/16
region : {{region}}
# After processing
vpc :
name : abc123-vpc
cidr : 10.0.0.0/16
region : us-west-2
Processed YAML is deserialized into Java configuration objects via Jackson :
@ Data
public class VpcConfig {
private String name ;
private String cidr ;
private String region ;
}
This library is used by all Fastish infrastructure projects:
Project
Description
Integration
aws-webapp-infra
Serverless web application stack
VPC, Cognito, DynamoDB, API Gateway, Lambda, SES
aws-eks-infra
EKS Kubernetes cluster
VPC, EKS, IAM, SQS
aws-druid-infra
Apache Druid analytics platform
VPC, EKS, RDS, S3, MSK
When deployed through the Fastish platform, additional internal services coordinate deployment automation:
Component
Purpose
Orchestrator
Release pipeline automation via CodePipeline
Portal
Multi-tenant subscriber management
Network
Shared VPC infrastructure
Reporting
Usage metering and cost attribution
Variable
Type
Description
{{account}}
String
AWS account ID
{{region}}
String
AWS region
{{environment}}
String
Environment name (e.g., prototype)
{{version}}
String
Resource version (e.g., v1)
{{hosted:id}}
String
Unique deployment identifier
{{domain}}
String
Route 53 domain name
# Simple substitution
name : {{hosted:id}}-resource
# Conditional sections
{{#enabled}}
feature :
active : true
{{/enabled}}
# Iteration
subnets :
{{#subnets}}
- id : {{id}}
cidr : {{cidr}}
{{/subnets}}
# Inverted sections (if not)
{{^production}}
debug : true
{{/production}}
See: Mustache Manual
# Verify Maven build
mvn clean install -DskipTests
# Check for dependency conflicts
mvn dependency:tree | grep -i conflict
# Validate Mustache template syntax
mvn test -Dtest=TemplateProcessorTest
# Debug template resolution
mvn -X cdk synth 2>&1 | grep -i " template\|mustache"
# Verify context injection
cat cdk.context.json | jq ' .'
Issue
Symptom
Resolution
Template not found
FileNotFoundException during synthesis
Verify environment/version path exists in src/main/resources/
Mustache syntax error
MustacheException with template location
Check for unclosed tags {{#section}}...{{/section}}
YAML parsing failure
JsonMappingException during deserialization
Validate YAML syntax and ensure fields match POJO properties
Context variable missing
null values in generated resources
Add missing variable to cdk.context.json
Version mismatch
CDK synthesis errors
Ensure cdk-common version matches infrastructure project
For detailed troubleshooting procedures, see the Troubleshooting Guide .
MIT License
For your convenience, you can find the full MIT license text at: