You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Automated, production-ready infrastructure using Terraform — App servers in private subnets, RDS in fully isolated subnets, across 2 Availability Zones.
An EC2 Key Pair already created in the target region
Your public IP address for bastion SSH access
🚀 Deployment Steps
# 1. Copy and fill in your values
cp terraform.tfvars.example terraform.tfvars
# 2. Initialise providers and modules
terraform init
# 3. Preview what will be created
terraform plan
# 4. Deploy (~12–15 min, mostly RDS Multi-AZ provisioning)
terraform apply
📤 Outputs After Apply
terraform output
Output
Description
bastion_public_ip
Public IP of the bastion host
bastion_ssh_command
Ready-to-paste SSH command
rds_endpoint
RDS hostname:port
private_subnet_ids
App-tier subnet IDs
isolated_subnet_ids
DB-tier subnet IDs
🔌 Connecting Through the Bastion
# SSH to bastion
ssh -i ~/.ssh/<key-pair>.pem ec2-user@<bastion_public_ip># From bastion → RDS
mysql -h <rds_hostname> -u admin -p appdb
# Local port-forward so you can use a local MySQL client
ssh -i ~/.ssh/<key-pair>.pem \
-L 3307:<rds_hostname>:3306 \
ec2-user@<bastion_public_ip> -N &
mysql -h 127.0.0.1 -P 3307 -u admin -p appdb
🧹 Tear Down
# Dev
terraform destroy
# Prod — turn off deletion protection first, then destroy
terraform apply -var='environment=dev'
terraform destroy
✅ Production Checklist
Store db_password in AWS Secrets Manager, reference via data source
Add an Application Load Balancer in front of the ASG
Enable VPC Flow Logs → S3 for network audit trail
Add AWS WAF to the ALB
Use S3 + DynamoDB for Terraform remote state and locking