This Terraform code creates multiple Virtual Private Clouds (VPCs) in a single region, each with 3 public subnets and 3 private subnets spread across different availability zones. It also creates an Internet Gateway and attaches it to the VPC, creates public and private route tables, and associates the subnets with their respective route tables.
Before running this Terraform code, you will need the following:
- AWS account
- Terraform installed on your local machine
- AWS CLI installed on your local machine
- Rename the "template_terraform.tfvars" to "terraform.tfvars" and provide appropriate values
- Clone this repository to your local machine.
- Navigate to the project directory.
- Initialize the working directory by running terraform init.
terraform init - Validate the configuration by running terraform validate.
terraform validate or terraform validate -var-file="variables.tfvars" - Preview the changes that will be made by running terraform plan.
terraform plan - Apply the changes by running terraform apply.
terraform apply - When you are finished, tear down the infrastructure by running terraform destroy.
terraform destroy
This Terraform code creates the following resources:
- VPCs
- Subnets
- Internet Gateway
- Route Tables
- Route Table Associations
- Launch Template
- Auto Scaling Group
- Load Balancer
- Target Group
- RDS instance
- Route53 record
- S3 Bucket