Back to Projects
iac automation

Automated Terraform IaC Modules

Highly secure, modular Infrastructure as Code (IaC) architectures for AWS. Deploys standard multi-tier VPCs, Auto Scaling Groups, S3 buckets, and IAM roles using custom-built HCL modules with robust locking backends.

πŸ’‘ What We Will Learn in This Repo

  • 1

    Modular HCL Code structuring

    Construct highly customizable Terraform modules exposing defined variables and output values for external compositions.

  • 2

    Encrypted Remote State backends

    Learn to store resource state logs securely using KMS encrypted S3 buckets in AWS.

  • 3

    Dynamic DynamoDB State Locking

    Assert DynamoDB tables to lock state maps during execution, preventing write conflicts across team deployments.

  • 4

    High-Availability Auto Scaling Groups

    Provision VPC components alongside Auto Scaling groups to scale web applications dynamically across multiple zones.

πŸ“– Step-by-Step Installation Guide

1 Clone the Repository

Fetch the repository to your local workspace:

bash
git clone https://github.com/Pradeeptalari14/terraform-aws-modules.git
cd terraform-aws-modules
2 Bootstrap Backend Storage

Before applying resources, deploy the state storage S3 and DynamoDB table (configurations inside `backend-bootstrap/` folder):

bash
cd backend-bootstrap
terraform init
terraform apply -auto-approve
cd ..
3 Initialize Main IaC Modules

Configure backend references and download provider binaries for modules:

bash
terraform init
4 Validate and Apply Modules

Assert syntactic correct mappings and deploy the resources:

bash
terraform validate
terraform plan -out=tfplan
terraform apply tfplan

πŸ”„ Things You Need to Replace (Customization Checklist)

Adapt module parameters inside tfvars to target your specific deployment namespaces:

Target Element File Location Placeholder / Parameter key
globally Unique S3 Bucket providers.tf / backend-bootstrap/main.tf bucket = "your-tfstate-bucket-name" (must be unique)
DynamoDB Table Name providers.tf / backend-bootstrap/main.tf dynamodb_table = "terraform-locks" (locking lock key)
VPC IP Range mappings terraform.tfvars vpc_cidr = "10.0.0.0/16" (adjust subnets scope)
Allowed SSH IP scope terraform.tfvars allowed_ssh_cidr = ["0.0.0.0/0"] (narrow for security)

πŸ“Š Architectural Workflow

graph TD
    User[DevOps Engineer] -->|Terraform Apply| Client[Terraform CLI Engine]
    Client -->|Lock State| DynamoDB[DynamoDB Table]
    Client -->|Upload State File| S3[S3 Bucket - KMS Encrypted]
    
    subgraph Provisioned AWS Infrastructure
        Client -->|Provision VPC Module| VPC[High-Availability VPC]
        Client -->|Provision EC2 ASG Module| ASG[Auto Scaling Groups]
        Client -->|Provision IAM Role Module| IAM[IAM Policies]
    end
    
    ASG -->|Run Instances inside| VPC
    IAM -->|Attach execution keys to| ASG
            

πŸ› οΈ Useful Commands (Project Reference)

Common CLI tasks for validating HCL infrastructure files:

# Format code stylings recursively: terraform fmt -recursive # Verify syntax configurations: terraform validate # Inspect resource states list: terraform state list # Cleanly tear down resources: terraform destroy -auto-approve
πŸ“‹ Code copied to clipboard!