Infrastructure as Code practice — building production-grade AWS architectures with Terraform, automated with Python.
Four reps that progressively build a full production stack on AWS:
| Rep | What it builds | Key concepts |
|---|---|---|
| rep-01 | Single EC2 instance | init/plan/apply/destroy, providers, variables, state |
| rep-02 | User Data + IAM + CloudWatch | IAM roles, file(), depends_on, log retention |
| rep-03 | ALB + HTTPS + DNS | Data sources, ACM, listeners, SG chaining |
| rep-04 | Full stack: ASG + Launch Template | Launch templates, auto scaling, scaling policies |
| modules/ | Reusable modules | Module inputs/outputs, DRY environments |
| environments/ | Dev + Staging | Environment isolation, separate state |
Rep 04 creates the entire architecture in one terraform apply:
Cloudflare → ALB (HTTPS) → Auto Scaling Group → N × EC2 (Docker)
Automation scripts built alongside the Terraform work:
| Rep | What it builds |
|---|---|
| rep-03 | boto3 fleet report and SG auditor |
| rep-04 | infra-check CLI tool (fleet, sg-audit, logs) |
| rep-05 | FastAPI infra API (containerised) |
| rep-07 | Structured logging for cloud |
| rep-08 | Testing with mocks (moto, pytest) |
Shared scripts used across reps:
scripts/userdata.sh— EC2 bootstrap script (Docker + ECR pull + container start)
- AWS CLI configured (
aws sts get-caller-identitymust work) - Terraform >= 1.0
- Python >= 3.10
- Docker (for container builds)
cd terraform/rep-01
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your values
terraform init
terraform plan
terraform apply