Skip to content

cn-terraform/terraform-aws-networking

Repository files navigation

Networking Terraform Module for AWS

This Terraform module creates the base networking infrastructure on AWS.

Usage

Check valid versions on:

Install pre commit hooks.

Pleas run this command right after cloning the repository.

    pre-commit install

For that you may need to install the folowwing tools:

In order to run all checks at any point run the following command:

    pre-commit run --all-files

Requirements

Name Version
terraform >= 0.13
aws >= 4

Providers

Name Version
aws 5.17.0

Modules

No modules.

Resources

Name Type
aws_eip.nat resource
aws_internet_gateway.internet_gw resource
aws_nat_gateway.nat resource
aws_route.private_internet_route resource
aws_route.public_internet resource
aws_route_table.private resource
aws_route_table.public resource
aws_route_table_association.private resource
aws_route_table_association.public resource
aws_subnet.private resource
aws_subnet.public resource
aws_vpc.vpc resource

Inputs

Name Description Type Default Required
additional_tags (Optional) A map of tags to assign to all the resources. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level. map(string) {} no
cidr_block (Optional) The IPv4 CIDR block for the VPC. CIDR can be explicitly set or it can be derived from IPAM using ipv4_netmask_length string null no
enable_dns_hostnames (Optional) A boolean flag to enable/disable DNS hostnames in the VPC. Defaults false. bool false no
enable_dns_support (Optional) A boolean flag to enable/disable DNS support in the VPC. Defaults to true. bool true no
enable_network_address_usage_metrics (Optional) Indicates whether Network Address Usage metrics are enabled for your VPC. Defaults to false. bool false no
instance_tenancy (Optional) A tenancy option for instances launched into the VPC. Default is default, which ensures that EC2 instances launched in this VPC use the EC2 instance tenancy attribute specified when the EC2 instance is launched. The only other option is dedicated, which ensures that EC2 instances launched in this VPC are run on dedicated tenancy instances regardless of the tenancy attribute specified at launch. This has a dedicated per region fee of $2 per hour, plus an hourly per instance usage fee. string "default" no
ipv4_ipam_pool_id (Optional) The ID of an IPv4 IPAM pool you want to use for allocating this VPC's CIDR. IPAM is a VPC feature that you can use to automate your IP address management workflows including assigning, tracking, troubleshooting, and auditing IP addresses across AWS Regions and accounts. Using IPAM you can monitor IP address usage throughout your AWS Organization. string null no
ipv4_netmask_length (Optional) The netmask length of the IPv4 CIDR you want to allocate to this VPC. Requires specifying a ipv4_ipam_pool_id. number null no
map_public_ip_on_launch (Optional) Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is false. bool false no
private_subnets (Optional) Map of objects contining the definition for each private subnet
map(object({
availability_zone = string # Availability Zone for the subnet.
cidr_block = string # The IPv4 CIDR block for the subnet.
}))
{} no
private_subnets_additional_tags (Optional) A map of tags to assign to the resource. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level. map(string) {} no
private_subnets_enable_resource_name_dns_a_record_on_launch (Optional) Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: false. bool false no
private_subnets_enable_resource_name_dns_aaaa_record_on_launch (Optional) Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: false. bool false no
public_subnets (Optional) Map of objects contining the definition for each public subnet
map(object({
availability_zone = string # Availability Zone for the subnet.
cidr_block = string # The IPv4 CIDR block for the subnet.
}))
{} no
public_subnets_additional_tags (Optional) A map of tags to assign to the resource. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level. map(string) {} no
public_subnets_enable_resource_name_dns_a_record_on_launch (Optional) Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: false. bool false no
public_subnets_enable_resource_name_dns_aaaa_record_on_launch (Optional) Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: false. bool false no
single_nat Use single NAT Gateway bool false no
vpc_additional_tags (Optional) A map of tags to assign to the VPC resource. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level. map(string) {} no

Outputs

Name Description
internet_gateway_id ID of the generated Internet Gateway
nat_gws n/a
private_subnets ------------------------------------------------------------------------------ AWS Subnets - Private ------------------------------------------------------------------------------
private_subnets_route_tables n/a
public_subnets ------------------------------------------------------------------------------ AWS Subnets - Public ------------------------------------------------------------------------------
public_subnets_route_tables n/a
vpc_arn Amazon Resource Name (ARN) of VPC
vpc_default_network_acl_id The ID of the network ACL created by default on VPC creation
vpc_default_route_table_id The ID of the route table created by default on VPC creation
vpc_default_security_group_id The ID of the security group created by default on VPC creation
vpc_enable_dns_hostnames Whether or not the VPC has DNS hostname support
vpc_enable_dns_support Whether or not the VPC has DNS support
vpc_enable_network_address_usage_metrics Whether Network Address Usage metrics are enabled for the VPC
vpc_id The ID of the VPC
vpc_instance_tenancy Tenancy of instances spin up within VPC
vpc_ipv6_association_id The association ID for the IPv6 CIDR block.
vpc_ipv6_cidr_block_network_border_group The Network Border Group Zone name
vpc_main_route_table_id The ID of the main route table associated with this VPC. Note that you can change a VPC's main route table by using an aws_main_route_table_association.
vpc_owner_id The ID of the AWS account that owns the VPC.
vpc_tags_all A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.