From manual EC2 to S3 Remote State - step by step production IaC
- Launched EC2 via AWS Console
- Deployed Flask app on port 5000 with user_data
- Understood EC2, Security Groups, SSH basics
- Installed Nginx on EC2
- Configured reverse proxy:
80 → 5000 - App now accessible on
http://<EC2_IP>without port - Learned production routing pattern
- Converted manual infra to Terraform
- Created
main.tf,variables.tf,outputs.tf - Fixed SG
already existserror - learned importance ofterraform.tfstate - First successful
terraform apply / destroycycle
-
Created S3 bucket
devops-tfstate-anuj-2026(encrypted + versioned) -
Added backend block with native locking
backend "s3" { bucket = "devops-tfstate-anuj-2026" key = "devops-app/terraform.tfstate" region = "eu-north-1" use_lockfile = true }
-
Migrated: terraform init -migrate-state -upgrade
-
Deleted local tfstate - terraform state list still works from S3
⚡️ Quick Deploy
git clone https://github.com/<username>/devops-ec2-deploy.git
cd devops-ec2-deploy/terraform
terraform init
terraform apply
App: http://<EC2_IP> (via Nginx) | Direct: :5000 Health: /health | Info: /api/info
terraform destroy
- EC2: t3.micro, Ubuntu 22.04, eu-north-1
- Proxy: Nginx 80 → Flask 5000
- SG: 22, 80, 5000
- State: S3 Remote + Native Locking
- App: Production Dashboard
Branch: level-4-remote-state | Release: level-4-complete
Built by: Anuj Yadav