main
Move networking, security group, and EC2 resources into reusable modules under terraform/modules and wire them from main.tf. Add READMEs and update test notes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DevOps-Danan Infrastructure Architecture & Terraform Modules
Production-grade AWS infrastructure managed with Terraform, featuring high availability across 2 Availability Zones, isolated network tiers, and modular architecture.
Architecture Diagram
graph TD
Internet((Internet / End Users))
subgraph AWS_Cloud ["AWS Region: us-west-1"]
subgraph VPC ["Dedicated VPC (10.0.0.0/16)"]
IGW["Internet Gateway"]
Internet --- IGW
subgraph Public_Tier ["Public Subnets (DMZ)"]
subgraph AZ_A_Pub ["AZ: us-west-1a"]
PubSub1["Public Subnet 1 (10.0.1.0/24)"]
PubEC2["Public EC2 (Nginx Web Server)"]
NAT["NAT Gateway + Elastic IP"]
end
subgraph AZ_B_Pub ["AZ: us-west-1b"]
PubSub2["Public Subnet 2 (10.0.2.0/24)"]
end
end
subgraph Private_Tier ["Private Subnets (Isolated)"]
subgraph AZ_A_Priv ["AZ: us-west-1a"]
PrivSub1["Private Subnet 1 (10.0.11.0/24)"]
PrivEC2["Private EC2 (Nginx Web Server)"]
end
subgraph AZ_B_Priv ["AZ: us-west-1b"]
PrivSub2["Private Subnet 2 (10.0.12.0/24)"]
end
end
end
end
IGW --> PubSub1
IGW --> PubSub2
PubEC2 --- PubSub1
NAT --- PubSub1
PubEC2 -.->|SSH & HTTP (SG Restricted)| PrivEC2
PrivEC2 -->|Outbound Updates via 0.0.0.0/0| NAT
NAT --> IGW
Repository Structure
Devops-Danan/
├── README.md # Main repository documentation & guide
├── danan_test.txt # Test deployment outputs log
├── Note.txt # Architecture specification notes
└── terraform/ # Root Terraform deployment configuration
├── README.md # Terraform deployment instructions
├── main.tf # Root module invoking child modules
├── variables.tf # Configurable inputs & defaults
├── outputs.tf # Exported endpoints and IPs
├── provider.tf # AWS provider settings
├── versions.tf # Terraform & provider version constraints
└── modules/ # Reusable Terraform child modules
├── README.md # Module specifications and interfaces
├── vpc/ # VPC, subnets, IGW, NAT GW, route tables
├── security/ # Public & private security groups
└── compute/ # EC2 instances & web servers
Modular Architecture Overview
| Module | Location | Description |
|---|---|---|
| VPC | modules/vpc | Dedicated VPC with 2 public & 2 private subnets across 2 AZs, IGW, NAT GW, and EIP. |
| Security | modules/security | Public SG (HTTP/SSH from 0.0.0.0/0) and Private SG (traffic allowed only from Public SG). |
| Compute | modules/compute | Provisions Public EC2 (with public IP & Nginx) and Private EC2 (behind NAT GW & Nginx). |
Deployment Quickstart
Prerequisites
Step 1: Initialize
cd terraform
terraform init
Step 2: Validate & Review Plan
terraform validate
terraform plan -out=tfplan
Step 3: Deploy
terraform apply "tfplan"
Step 4: Verify Web Server & Connectivity
# Get public IP
PUBLIC_IP=$(terraform output -raw public_ec2_public_ip)
# Test HTTP response
curl http://${PUBLIC_IP}
Expected response:
<h1>Hello Danan from Public EC2 (...)</h1>
Step 5: Clean Up (Destroy)
To prevent unexpected AWS charges when done testing:
terraform destroy
Caution
The NAT Gateway and Elastic IP incur hourly AWS charges while running. Remember to run
terraform destroywhen your lab or testing is complete.
Languages
HCL
100%