← Back to Projects
🏗️

Production-Grade 3-Tier App on AWS Using Terraform & AI

42 AWS resources. One command. A real production architecture built from scratch.

PlatformAWS
IaC ToolTerraform
StackNext.js · Node.js · MySQL RDS · ALB · Nginx
Resources Deployed42 AWS Resources
Read on MediumView Article →

Architecture

3-Tier Design

Internet ↓ Public Application Load Balancer ↓ WEB TIER (Public Subnets — AZ1: 10.0.1.0/24, AZ2: 10.0.2.0/24) Next.js frontend served via Nginx ↓ Internal Application Load Balancer ↓ APP TIER (Private Subnets — AZ1: 10.0.3.0/24, AZ2: 10.0.4.0/24) Node.js REST API on port 3001 ↓ DATABASE TIER (Private Subnets — AZ1: 10.0.5.0/24, AZ2: 10.0.6.0/24) RDS MySQL 8.0 Multi-AZ + Read Replica Security Groups: Each tier only accepts traffic from the tier DIRECTLY above it.
42
AWS Resources
6
Subnets across 2 AZs
Multi-AZ
RDS + Read Replica
15 min
Full deploy time

What Broke & How I Fixed It

PROBLEM 1

The # symbol that broke everything

RDS password was BookReview#2024! — the # is treated as a comment start by dotenv. Backend was connecting as "BookReview" only. Fix: removed special characters from the password entirely.

PROBLEM 2

Node.js 12 on Ubuntu 22.04 — build crashed immediately

Ubuntu 22.04 ships Node.js 12. The app needed Node.js 18. Fix: removed default Node, installed v18 via NodeSource setup script.

PROBLEM 3

Claude Code ran out of credits mid-deployment

Backend half configured, frontend half built. This forced me to finish manually — proving I actually understood what the AI was doing, not just watching it run. Lesson: always understand your tools, not just use them.

PROBLEM 4

Missing .env file — backend crashing silently

PM2 was running but the app kept failing. No .env file existed on the app instances. Fix: SSH'd into each instance and created the .env file manually with the correct RDS endpoint and credentials.

Key Skills

What I Learned

Infrastructure as Code Changes Everything

terraform destroy deleted all 42 resources in 8 minutes. terraform apply rebuilt them in 15. Create and destroy entire production environments on demand — that is the superpower of IaC.

AI Amplifies Engineers — It Doesn't Replace Them

Claude Code generated 400+ lines of Terraform in minutes. But when it ran out of credits I had to finish manually. Engineers who win with AI understand what it is doing, not just that it is doing it.

Special Characters in Passwords Break dotenv

#, @, ! can all break dotenv parsing. Always test .env files and verify database connections before deploying the full app stack.

Design Architecture Before Writing Code

The architecture diagram saved hours. Knowing exactly what connects to what before writing Terraform means fewer surprises mid-deployment and cleaner security group design.

TerraformAWS VPCALBRDS Multi-AZNext.jsNode.jsNginxInfrastructure as CodeClaude Code
Read Full Article on Medium →