This repository contains the Infrastructure as Code (IaC) for the Cloud Resume Challenge, implementing a serverless resume website with visitor counter functionality on AWS using Terraform.
Live Site: lukamasa.com
Frontend Repository: greqq/cloud-resume
βββββββββββββββ
β Cloudflare β DNS Management
β DNS β lukamasa.com β CloudFront
ββββββββ¬βββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AWS Infrastructure β
β β
β ββββββββββββββββ βββββββββββββββ β
β β CloudFront ββββββββ S3 Bucket β Website Hosting β
β β (CDN) β β (Private) β β
β ββββββββββββββββ βββββββββββββββ β
β β
β ββββββββββββββββ βββββββββββββββ βββββββββββββ β
β β API Gateway ββββββββ Lambda ββββββββ DynamoDB β β
β β (REST API) β β (Python) β β Tables β β
β ββββββββββββββββ βββββββββββββββ βββββββββββββ β
β β
β ββββββββββββββββ βββββββββββββββ β
β β CloudWatch ββββββββ SNS β Monitoring β
β β Alarms β β Topics β β
β ββββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Module | Purpose | Key Resources |
|---|---|---|
| s3 | Static website hosting | S3 bucket with CloudFront OAC |
| cloudfront | CDN with HTTPS | Distribution, cache policy, OAC |
| certificate | SSL/TLS certificate | ACM certificate (DNS validation) |
| lambda | Visitor counter logic | Python function, IAM role |
| api_gateway | REST API endpoint | API Gateway with CORS support |
| dynamodb | Visitor count storage | VisitorCounter table |
| dynamodb_unique_visits | Unique visitor tracking | UniqueVisitors table |
| monitoring | Alarms & notifications | CloudWatch alarms, SNS topics |
- Terraform: v1.12.0 or higher
- AWS CLI: Configured with SSO
- AWS Account: With appropriate permissions
- Git: For version control
-
Clone the repository:
git clone https://github.com/greqq/terraform-aws-infrastructure.git cd terraform-aws-infrastructure -
Login to AWS SSO:
./aws-login.sh # Or manually: aws sso login --profile FullAccessLambdaDynamo-591968772652 export AWS_PROFILE=FullAccessLambdaDynamo-591968772652
-
Initialize Terraform:
cd environments/production terraform init -backend-config=backend.conf -
Review planned changes:
terraform plan
-
Apply infrastructure:
terraform apply
terraform-aws-infrastructure/
βββ README.md
βββ aws-login.sh # AWS SSO login helper
βββ setup-dev-environment.sh # Dev environment setup
β
βββ environments/
β βββ development/ # Dev environment (isolated testing)
β β βββ main.tf
β β βββ variables.tf
β β βββ outputs.tf
β β
β βββ production/ # Production environment
β βββ main.tf # Module composition
β βββ variables.tf # Variable definitions
β βββ terraform.tfvars # Configuration values
β βββ outputs.tf # Exported values
β βββ backend.conf # S3 backend config
β
βββ modules/ # Reusable infrastructure components
βββ api_gateway/
βββ certificate/
βββ cloudfront/
βββ dynamodb/
βββ dynamodb_unique_visits/
βββ lambda/
βββ monitoring/
βββ s3/
Terraform state is stored remotely in S3 with DynamoDB locking to prevent concurrent modifications:
bucket = "terraform-state-webflow-lma"
key = "global/s3/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-up-and-running-locks"| Variable | Value | Description |
|---|---|---|
domain_name |
lukamasa.com |
Primary domain |
bucket_name |
cloud-resume-lma |
S3 bucket for website |
function_name |
incrementCounter |
Lambda function name |
billing_mode |
PAY_PER_REQUEST |
DynamoDB billing (serverless) |
environment_type |
prod |
Environment identifier |
The frontend repository uses GitHub Actions to:
- Pull infrastructure outputs from Terraform
- Build Next.js app with correct API URL (
NEXT_PUBLIC_API_URL) - Deploy to S3 bucket
- Invalidate CloudFront cache
Workflow: .github/workflows/ci.yaml in cloud-resume
cd environments/production
terraform plan # Review changes
terraform apply # Apply changesterraform show
terraform state list # List all resources# β οΈ CAUTION: This will destroy all infrastructure!
terraform destroyterraform force-unlock <LOCK_ID>- Modify or create module in
modules/ - Update
environments/production/main.tfto use module - Add variables to
terraform.tfvarsif needed - Run
terraform planandterraform apply
- Cloud Resume Challenge by Forrest Brazeal