Multi-region AWS CDK application deploying production-ready static websites with CloudFront CDN and automated CI/CD.
- CloudFront distribution with optimized S3 origin and OAI
- ACM certificates in us-east-1 for CloudFront compatibility
- CodePipeline/CodeBuild CI/CD with GitHub CodeStar integration
- Multi-domain support with domain-specific configurations
- External DNS provider support (Hover, GoDaddy)
- AWS CLI configured with credentials
- AWS CDK CLI installed (
npm install -g aws-cdk) - Java 25+
- Maven
- AWS account bootstrapped for CDK (see Bootstrap section)
Before first deployment, bootstrap your AWS account for CDK. This creates the necessary resources (S3 bucket, IAM roles) for CDK deployments.
Important: This project creates certificates for CloudFront, which must be in the us-east-1 region. Always bootstrap us-east-1 regardless of your primary region.
# Bootstrap both your main region and us-east-1
cdk bootstrap aws://ACCOUNT-NUMBER/us-east-1
cdk bootstrap aws://ACCOUNT-NUMBER/eu-central-1aws cloudformation describe-stacks --stack-name CDKToolkit --region us-east-1CloudFormation stacks follow the pattern: {appName}-{normalizedDomain}-{stackType}
appName: cicd-websitenormalizedDomain: Domain name with dots replaced by hyphens (e.g., example-com)stackType: certificate, cloudfront, or codepipeline
Example stack names for domain example.com:
cicd-website-example-com-certificate(us-east-1)cicd-website-example-com-cloudfront(target region)cicd-website-example-com-codepipeline(target region)
Configuration files are loaded in this order (later sources override earlier ones):
~/.aws-cicd-website-cdk/{domain}.properties(global, domain-specific)./app.properties(local, overwrites global)- System properties (highest priority)
Example paths for domain example.com:
~/.aws-cicd-website-cdk/example.com.properties./app.properties
# Domain configuration
domain.name=example.com
# External DNS provider (default: false)
# Set to true if using Hover, GoDaddy, etc.
external.dns.provider=false
# GitHub integration
codestar.connection.arn=arn:aws:codestar-connections:region:account:connection/xxx
git.owner=your-github-username
git.repository=your-repo-name
git.branch=main
# Certificate validation (for external DNS)
cert.validation.record.name=_xxx.example.com
cert.validation.domain.name=_xxx.acm-validations.aws.cdk deploy --context domain=example.com- Set
external.dns.provider=truein configuration - Deploy:
cdk deploy --context domain=example.com - Add CNAME validation record from us-east-1 ACM to your DNS provider. Otherwise the CDK deployment will block.
- Wait for certificate validation to complete
- Add CloudFront distribution CNAME/A records to your DNS provider
- Set
external.dns.provider=truein configuration - Deploy:
cdk deploy --context domain=example.com - Add CNAME validation record from us-east-1 ACM to your DNS provider. Otherwise the CDK deployment will block.
- Wait for certificate validation to complete
- CDK will create a public hosted zone in us-east-1
- Pick the DNS server from the created hosted zone and configure your DNS registrar to use them.
DOMAIN=example.com cdk deployWhen using providers like Hover, the CDK automatically creates:
- Route53 hosted zone for your domain
- A and AAAA alias records pointing to CloudFront
Manual steps required:
-
Update nameservers: Point your domain to AWS Route53 nameservers
- Find the nameservers in Route53 console for your hosted zone (4 NS records)
- Update nameserver settings in your external DNS provider (Hover, GoDaddy, etc.)
- DNS propagation may take up to 48 hours
-
Certificate validation: Add the ACM validation CNAME record
- The certificate validation CNAME is created in us-east-1 region
- Find the validation record in AWS Certificate Manager console (us-east-1)
- Add this CNAME record to your external DNS provider within 72 hours
- Keep the record permanently for automatic certificate renewal
CDKApp- Main application entry pointConfiguration- Configuration managementDomainCertificateStack- ACM certificate creation (us-east-1)CloudFrontStack- CloudFront distribution and S3 bucketCodeBuildStack- CI/CD pipeline for automatic deployments
buildAndDeploy.sh- Build and deploy the CDK applicationbuildAndDeployDontAsk.sh- Deploy without confirmationdestroy.sh- Tear down all stacks
- CloudFront Certificates: ACM certificates used with CloudFront distributions must be created in the us-east-1 region. The
DomainCertificateStackautomatically deploys to us-east-1 for this reason - Stack deployment waits for DNS validation when using external providers
- Configuration files in user directory take precedence over project directory
- The certificate stack is deployed separately in us-east-1 while other resources can be in your preferred region