export AWS_ACCESS_KEY_ID=[YOUR_ACCESS_KEY_HERE]
export AWS_SECRET_ACCESS_KEY=[YOUR_SECRET_ACCESS_KEY_HERE]
export AWS_REGION=[YOUR_REGION_HERE]
terragrunt init
terragrunt apply -target=module.vpc -target=module.igw -target=module.eip
terragrunt apply -target=module.nat -target=module.routes
https://terraform-docs.io/user-guide/installation/
terraform-docs .
This module creates 3 Public facing subnets and multiple triads of private subnets as long as the VPC CIDR can accomodate the address space.
Please take a look at values.hcl
for more information about module setup and usage.
The module uses cidrsubnets function to calculate subnets CIDRs. So please refer to that documentation in setting up new_bits
for each subnet.
We can add more private subnets using this VPC module as shown in the below example.
subnets = [
{
name = "Public Subnet 1"
new_bits = 4
az = "a"
},
{
name = "Public Subnet 2"
new_bits = 4
az = "b"
},
{
name = "Public Subnet 3"
new_bits = 4
az = "c"
},
{
name = "Web Subnet 1"
new_bits = 4
az = "a"
},
{
name = "Web Subnet 2"
new_bits = 4
az = "b"
},
{
name = "Web Subnet 3"
new_bits = 4
az = "c"
},
{
name = "Data Subnet 1"
new_bits = 4
az = "a"
},
{
name = "Data Subnet 2"
new_bits = 4
az = "b"
},
{
name = "Data Subnet 3"
new_bits = 4
az = "c"
},
{
name = "Bastion Subnet 1"
new_bits = 4
az = "a"
},
{
name = "Bastion Subnet 2"
new_bits = 4
az = "b"
},
{
name = "Bastion Subnet 3"
new_bits = 4
az = "c"
}
]
Name | Version |
---|---|
aws | 4.34.0 |
No providers.
Name | Source | Version |
---|---|---|
eip | ./modules/eip | n/a |
igw | ./modules/igw | n/a |
nat | ./modules/nat | n/a |
routes | ./modules/routes | n/a |
vpc | ./modules/vpc | n/a |
No resources.
Name | Description | Type | Default | Required |
---|---|---|---|---|
cidr_block | VPC CIDR block | string |
n/a | yes |
enable_dns_hostnames | A boolean flag to enable/disable DNS hostnames in the VPC | bool |
false |
no |
enable_dns_support | A boolean flag to enable/disable DNS support in the VPC. | bool |
false |
no |
region | AWS region to deploy the resources. | string |
n/a | yes |
subnets | Subnet information necessary to create all the subnets. Please check cidrsubnets for more info on new_bits . The region variable is used to associate the desired AZ. Usage : join("",["us-east-1", "a"]) . Example: values.hcl |
list(object({ |
n/a | yes |
tags | VPC Tags | map(string) |
n/a | yes |
vpc_name | VPC Name | string |
"IaC VPC" |
no |
Name | Description |
---|---|
eip | Elastic IP address information |
eip_map | Elastic IP address information with subnet mapping |
igw | Internet Gateway Information. |
nat_gw | NAT Gateway information with the Subnet and EIP allocation ID. |
private_subnet_ids | Map of Private Subnet and associated subnet id created.private_subnet_ids = {"Web or Data Subnet 1" = { "subnet_id" = "subnet-xxxxxxx"} |
public_route | Public Route ID - Traffic to Internet Gateway |
public_route_table | Public Route Table ID. |
public_subnet_ids | Map of Public Subnet and associated subnet id created.public_subnet_ids = {"Public Subnet 1" = { "subnet_id" = "subnet-xxxxxxx"} |
route_table_az1 | Private Route Table ID - AZ1 |
route_table_az2 | Private Route Table ID - AZ2 |
route_table_az3 | Private Route Table ID - AZ3 |
subnets | CIDR information associated with each subnet. |
vpc_arn | Amazon Resource Name (ARN) of VPC |
vpc_id | The ID of the VPC |