Terraform module which creates VPC, Subnet, IG, EIP, NAT Gateway on AWS.
This module is to help you create vpc resources in AWS. Please refer to Examples for examples of usage. In the following, I will explain the usage and structure in a simple way.
#######
# VPC #
#######
module "network" {
source = "../../"
project_name = "simple"
environment_name = "example"
vpc_cidr = "10.0.0.0/16"
region_name = "ap-northeast-2"
availability_zones = ["a", "c"]
without_nat = false
create_nat_per_az = true
nat_deploy_module = "bastion"
public_subnets = {
front = ["10.0.0.0/21", /* "10.0.8.0/21", */ "10.0.16.0/21", /* "10.0.24.0/21" */]
# front2 = ["10.0.32.0/21", "10.0.40.0/21", "10.0.48.0/21", "10.0.56.0/21"]
bastion = ["10.0.62.0/26", /* "10.0.62.64/26", */ "10.0.62.128/26", /* "10.0.62.192/26" */]
}
public_subnets_tag = {
front = {
"kubernetes.io/role/elb" = 1
}
}
private_subnets = {
personal = ["10.0.64.0/20", /* "10.0.80.0/20", */ "10.0.96.0/20", /* "10.0.112.0/20" */]
# rest = ["10.0.128.0/20", "10.0.144.0/20", "10.0.160.0/20", "10.0.176.0/20"]
database = ["10.0.192.0/21", /* "10.0.200.0/21", */ "10.0.208.0/21", /* "10.0.216.0/21" */]
}
private_subnets_tag = {
personal = {
"kubernetes.io/role/internal-elb" = 1
}
}
}
Name | Version |
---|---|
aws | ~> 4.0 |
Name | Version |
---|---|
aws | ~> 4.0 |
Name | Source | Version |
---|---|---|
namer | cawcaw253/namer/aws | 1.0.0 |
region | cawcaw253/region/aws | 1.0.0 |
Name | Type |
---|---|
aws_eip.nat | resource |
aws_internet_gateway.this | resource |
aws_nat_gateway.this | resource |
aws_route.internet_gateway | resource |
aws_route.nat_gateway | resource |
aws_route_table.private_route | resource |
aws_route_table.public_route | resource |
aws_route_table_association.private_route | resource |
aws_route_table_association.public_route | resource |
aws_subnet.private_subnet | resource |
aws_subnet.public_subnet | resource |
aws_vpc.this | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
availability_zones | list of availability zones which use | list(string) |
[ |
no |
create_nat_per_az | Boolean value for create nat gateway per availability zones. If value is true, create nat gateway per azs, if false create only 1 nat gateway and share it | bool |
true |
no |
default_tags | Default tags | map(string) |
{} |
no |
environment_name | Name of environment | string |
"dev" |
no |
nat_deploy_module | The name of the module in which to deploy the NAT gateway. Module is key value of public_subnets variable. | string |
null |
no |
private_subnets | Configurations of private subnet | map(list(string)) |
n/a | yes |
private_subnets_tag | Setting tag to specific private subnet | map(map(string)) |
{} |
no |
project_name | Name of project | string |
n/a | yes |
public_subnets | Configurations of public subnet | map(list(string)) |
n/a | yes |
public_subnets_tag | Setting tag to specific public subnet | map(map(string)) |
{} |
no |
region_name | name of aws region. if not set value, it automatically set providers current region. | string |
null |
no |
vpc_cidr | CIDR Block for the VPC | string |
n/a | yes |
without_nat | Boolean value for using nat gateway or not | bool |
false |
no |
Name | Description |
---|---|
availability_zones | List of Availability Zones where subnets were created |
igw_id | The ID of the Internet Gateway |
nat_gateway_ids | IDs of the NAT Gateways created |
private_route_table_ids | IDs of the created private route tables |
private_subnet_cidrs | CIDR list of private subnets |
private_subnet_ids | ID list of private subnets |
public_route_table_ids | IDs of the created public route tables |
public_subnet_cidrs | CIDR list of public subnets |
public_subnet_ids | ID list of public subnets |
vpc_arn | The ARN of the VPC |
vpc_cidr_block | The primary IPv4 CIDR block of the VPC |
vpc_id | ID of the VPC |