Terraform | Simple 2-Tier AWS architecture

Project summary:

IAM Role:

  1. create IAM role with access to s3 and ec2

Networking and security:

  1. Create 1 VPC

  2. Create 4 subnet

    • Create 1 public subnet (app-tier) in az1

    • Create 1 public subnet (app-tier) in az2

    • Create 1 private subnet (db-tier) in az1

    • Create 1 private subnet (db-tier) in az2

  3. Create 1 Internet Gateway attach to VPC

  4. Create 1 Route table in VPC

    • Create 1 route table and attach to igw

    • Associate to app-tier public subnet (az1, az2)

  5. Create 3 security group in VPC

    • sg-1 for load balancer with inbound rule http→80, my laptop IP

    • sg-2 in public subnet for app tier with inbound rule http→80, my laptop IP and http→80, sg-1

    • sg-3 in private subnet for db tier with inbound rule tcp→3306, sg-2

Database Deployment:

  1. Create subnet group in RDS add 2 private subnet for db tier

  2. Create aws RDS instance

Load Balancing and Auto scaling deployment:

  1. Create AMI create AMI from running app tier instance

  2. Create target group

  3. Create LB

  4. Create launch template

  5. Create auto scaling

The complete terraform code for this project is available in my GitHub repo.

0
Subscribe to my newsletter

Read articles from Ilayaraja Veerakalai directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ilayaraja Veerakalai
Ilayaraja Veerakalai

DevOps Engineer with a strong background in Configuration Management and support roles, skilled in tools like AWS, Docker, Kubernetes, Terraform, and Ansible. I focus on automating processes, improving system performance, and making networks scalable and secure in cloud environments.