How saikiranpi/terraform_modules works
Project type and purpose
• This is a Terraform-based Infrastructure-as-Code (IaC) project that provides reusable AWS modules.
• It defines two distinct environments—development and production—each using the same set of modular building blocks (network, compute, ELB, IAM, NAT, security groups).
• Purpose: enable teams (QA, Dev, Prod) to spin up AWS resources independently, with clear separation of concerns and minimal code duplication.
File structure
• Top-level “development” and “production” directories each contain Terraform root modules (main.tf, variables.tf, terraform.tfvars) that orchestrate environment-specific resources.
• A “modules” directory houses library modules:
• network (VPC, public/private subnets, routing)
• nat (NAT gateways for private subnets)
• sg (security groups)
• iam (roles and instance profiles)
• elb (load balancer + listener definitions)
• compute (public/private EC2 instances)
• Terraform configuration files (.tf, .tfvars) define inputs, outputs, and environment parameters.
README insights
• Emphasizes a two-section architecture (development vs. production).
• Highlights modular design to tailor AWS resources per environment without rewriting code.
a. Main components
• Users/CI pipeline: triggers Terraform applies
• Environment workspaces: Development, Production
• Shared Modules Library: network, nat, sg, iam, elb, compute
• AWS Resources per module:
• VPC, subnets, route tables (Network)
• NAT Gateways (NAT)
• Security Groups (SG)
• IAM Roles & Instance Profiles (IAM)
• Elastic Load Balancer & Listeners (ELB)
• EC2 Instances (Compute)
b. Relationships & interactions
• Root modules in “development/main.tf” and “production/main.tf” each call the library modules in sequence:
1. network → 2. nat → 3. sg → 4. iam → 5. elb → 6. compute
• Data flow: outputs from network (e.g., VPC ID, subnet IDs) feed into NAT, SG, ELB, and compute modules.
• Compute instances attach to subnets, security groups, use IAM instance profiles, and register with the load balancer.
c. Architectural patterns / design principles
• Modular design: each concern isolated in its own Terraform module
• Environment segregation: separate state and configuration per environment
• Input/output contracts: modules communicate via well-defined variables and outputs
• Reusability and DRY: single source of truth for core infrastructure across environments
d. Key technologies
• Terraform CLI
• AWS services: VPC, EC2, ELB, NAT Gateway, IAM, Security Groups
• Terraform remote state (implied for environment isolation)