This project extends modular Terraform infrastructure by implementing a more realistic AWS architecture using public and private subnets. It introduces a private subnet with no direct internet access and uses a NAT Gateway to allow secure outbound connectivity.
- AWS VPC
- Public Subnet
- Private Subnet
- Internet Gateway
- NAT Gateway
- Route Tables (Public & Private)
- Route Table Associations
- Security Group (SSH access)
- EC2 Instance deployed in private subnet
- Dynamic AMI lookup using data source
- Public subnet hosts the Internet Gateway and NAT Gateway
- Private subnet contains the EC2 instance
- EC2 instance has no public IP (not directly accessible)
- Private subnet routes outbound traffic through the NAT Gateway
- Internet access flow:
EC2 (Private Subnet) → NAT Gateway → Internet Gateway → Internet
- Advanced AWS networking (public vs private subnets)
- NAT Gateway configuration and routing
- Secure infrastructure design
- Terraform modules and reusable architecture
- Module inputs and outputs
- Dynamic configuration using data sources
- VPC ID
- Public Subnet ID
- Private Subnet ID
- EC2 Instance ID
- EC2 Private IP
- Copied
.terraformand state files caused incorrect tracking of resources
- Deleted
.terraformand state files - Re-initialised Terraform using
terraform init
- Each Terraform project must have its own clean state
- Never copy
.terraformorterraform.tfstatebetween projects
- Add bastion host for secure SSH into private subnet
- Implement remote backend using S3 and DynamoDB
- Add load balancer for production setup
- Create environment separation (dev/prod)