This repository contains Terraform code to provision and manage AWS infrastructure using a modular approach.
AWS-Infrastructure-Terraform
├── environments
│ ├── dev
│ ├── staging
│ └── prod
│
└── modules
├── alb
├── ec2
│ └── templates
├── iam
│ └── policies
├── rds
├── s3
│ └── policies
├── security-groups
└── vpc
- environments/ – Environment-specific Terraform configurations (dev, staging, prod).
- modules/ – Reusable Terraform modules for AWS resources.
- vpc – Creates VPC, subnets, and networking components.
- security-groups – Manages security group rules.
- ec2 – Launches EC2 instances and related configurations.
- alb – Application Load Balancer setup.
- rds – RDS database resources.
- s3 – S3 buckets and policies.
- iam – IAM roles, policies, and permissions.
This repository uses GitHub Actions to automate Terraform validation and deployment.
Pipeline behavior:
| Branch | Environment | Action |
|---|---|---|
dev |
environments/dev |
Automatically deploys infrastructure |
stage |
environments/staging |
Automatically deploys infrastructure |
main |
environments/prod |
Runs Terraform plan on Pull Request and requires approval before apply |
The GitHub Actions workflow performs the following:
- Checkout repository
- Setup Terraform
- Configure AWS credentials
- Run
terraform init - Run
terraform validate - Run
terraform plan - Deploy infrastructure (
terraform apply) based on branch rules
Workflow file location:
.github/workflows/terraform.yml
- Navigate to the required environment:
cd environments/dev
- Initialize Terraform:
terraform init
- Plan the infrastructure:
terraform plan
- Apply the configuration:
terraform apply --auto-approve
- Terraform >= 1.x
- AWS CLI configured
- Appropriate AWS permissions