This repository provides Terraform configuration for creating a complete AWS VPC infrastructure. It creates a production-ready VPC setup with public and private subnets across multiple availability zones.
- VPC: Creates a VPC with customizable CIDR block (default: 10.0.0.0/16)
- Subnets:
- 3 Private subnets across different AZs
- 3 Public subnets across different AZs
- Automatic CIDR block calculation using
cidrsubnetfunction
- Networking:
- Internet Gateway for public internet access
- Public Route Table with route to Internet Gateway
- Private Route Table for internal networking
- Route Table Associations for all subnets
aws_region: AWS region (default: us-east-1)vpc_name: Name of the VPC (default: omini)vpc_cidr: VPC CIDR block (default: 10.0.0.0/16)private_subnets: Map of private subnet names and their numberpublic_subnets: Map of public subnet names and their numberaws_access_key_id: (optional) AWS access key. Defaults to theAWS_ACCESS_KEY_IDenvironment variable if unset.aws_secret_access_key: (optional) AWS secret key. Defaults to theAWS_SECRET_ACCESS_KEYenvironment variable if unset.
- VPC ID and CIDR block
- Public and Private Subnet IDs and CIDR blocks
- Route Table IDs
- Internet Gateway ID
- Region and Availability Zone information
- Clone the repository
- Configure AWS credentials using environment variables or an AWS credentials file. Do not add credentials to
terraform.tfvars, otherwise Terraform will warn about undefined variables. Example:export AWS_ACCESS_KEY_ID=your-access-key export AWS_SECRET_ACCESS_KEY=your-secret-key
- Modify variables in
variables.tfif needed - Run:
terraform init
terraform plan
terraform apply- Terraform >= 1.12
- AWS Provider
- AWS credentials configured