This repository contains a fully automated, production-ready AWS infrastructure built using Terraform.
It includes VPC networking, subnets, NAT gateways, bastion host, application servers, Network Load Balancer (NLB), Route53 DNS, ACM TLS certificates, Redis, RDS MySQL, Auto Scaling Group (ASG), and more.
The Terraform code provisions:
- 1 VPC
- Public and private subnets
- Internet Gateway
- NAT Gateway
- Route tables and routing configuration
- Security groups for public, private, database, and cache layers
- Bastion host (public subnet)
- Auto Scaling Group (private subnet)
- Launch Template based instances
- Min 1, Max 3
- CPU-based scale-in/scale-out
- Network Load Balancer (NLB)
- Listener ports: 80/TCP, 443/TLS, 8080/TCP
- Target Group automatically populated by ASG instances
- Hosted Zone via Route53
- ALIAS record → NLB
- ACM certificate with DNS validation
- TLS termination on NLB (port 443)
- RDS MySQL
- ElastiCache Redis (Redis 6.x)
Internet
│
Route53 (api.insung-terraform.com)
│
ACM (TLS Certificate)
│
Network Load Balancer (80 / 443 / 8080)
│
┌────────────────────────────────────────────┐
│ AWS VPC │
│ ┌───────────────────────────┐ │
│ │ Public Subnets │ │
│ │ - Bastion Host │ │
│ │ - NAT Gateway │ │
│ │ - RDS MySQL │ │
│ └───────────────────────────┘ │
│ ┌───────────────────────────┐ │
│ │ Private Subnets │ │
│ │ - ASG Auto EC2 (1~3) │ │
│ │ - Redis (ElastiCache) │ │
│ └───────────────────────────┘ │
└────────────────────────────────────────────┘
AWS-terraform/
├── vpc.tf
├── security.tf
├── ec2.tf
├── launch_template.tf
├── autoscaling.tf
├── nlb.tf
├── route53.tf
├── acm.tf
├── redis.tf
├── database.tf
├── variables.tf
├── outputs.tf
└── provider.tf
| Condition | Action |
|---|---|
| CPU ≥ 40% | Scale-Out (+1 instance) |
| CPU ≤ 20% | Scale-In (–1 instance) |
| Min Size | Always 1 |
| Max Size | Up to 3 |
- Terraform 1.3+
- AWS Account
- AWS CLI installed (
aws configure) - SSH keypair named
terraform_key - Route53 domain access
terraform init
terraform plan
terraform apply
terraform destroy
ssh -i terraform_key.pem ubuntu@<bastion_public_ip>
ssh ec2-user@<private_ec2_ip>
http://api.insung-terraform.com
https://api.insung-terraform.com
- Multi-VPC + Transit Gateway
- WAF integration
- CloudFront CDN
- ECS Fargate or EKS migration
- Centralized logging (OpenSearch)
- Terraform backend (S3 + DynamoDB)
- GitHub Actions CI/CD