This project demonstrates a server-side rendering (SSR) architecture using AWS CDK with Java. It implements a scalable system that combines serverless Lambda functions with containerized rendering services.
The application consists of these key components:
- CloudFront Distribution: Entry point for all user requests, with WAF protection
- S3 Bucket: Stores static assets (CSS, JS, images)
- ECS Fargate Service: Orchestrates the server-side rendering process
- Lambda Functions:
- Catalog Service: Manages product data
- Review Service: Handles customer reviews
- Notifications Service: Manages user notifications with SNS integration
- User requests arrive at CloudFront
- Static content is served directly from S3
- Dynamic API requests route to the Fargate service
- Fargate containers invoke Lambda functions to fetch data
- The rendered HTML is returned to the user
- Java 17+
- Maven 3.8+
- AWS CLI configured
- AWS CDK CLI installed (
npm install -g aws-cdk
) - Docker (for local testing)
-
Build the project:
mvn clean package
-
Deploy to AWS:
cdk deploy
-
Configure S3 and CloudFront:
# Create static folder and upload index.html aws s3api put-object --bucket <your-bucket-name> --key static/ aws s3 cp src/main/java/com/myorg/static/index.html s3://<your-bucket-name>/static/
Note: Update the CloudFront distribution to use Origin Access Control (OAC) instead of the legacy Origin Access Identity (OAI) for improved security. This can be done in the CloudFront console under the origin settings.
-
Access the application:
- The CloudFront URL will be displayed in the CDK output
- API endpoints are available at
/api/*
The Lambda functions require these environment variables:
CATALOG_TABLE_NAME
: DynamoDB table for catalog dataREVIEW_TABLE_NAME
: DynamoDB table for reviewsNOTIFICATIONS_TABLE_NAME
: DynamoDB table for notificationsNOTIFICATIONS_TOPIC_ARN
: SNS topic ARN for notifications
- WAF protection for CloudFront
- S3 bucket with blocked public access
- IAM permissions following least privilege principle
- CORS headers for API responses
- CloudWatch logs for Lambda functions and Fargate tasks
- CloudFront distribution metrics
- WAF security metrics
This project is licensed under the MIT License.