A Terraform module for creating an AWS VPC with options to create public and private subnets, NAT gateways, and Internet gateways.
module "vpc" {
source = "https://github.com/TerraformToolbox/terraform-aws-vpc"
region = "us-west-2"
cidr_block = "10.0.0.0/16"
vpc_name = "my-vpc"
}
module "vpc" {
source = "https://github.com/TerraformToolbox/terraform-aws-vpc"
region = "us-west-2"
cidr_block = "10.0.0.0/16"
enable_dns_support = true
enable_dns_hostnames = true
instance_tenancy = "default"
vpc_name = "my-vpc"
tags = { "Environment" = "dev" }
create_subnets = true
create_internet_gateway = true
create_nat_gateway = true
public_subnet_cidrs = ["10.0.1.0/24", "10.0.2.0/24"]
private_subnet_cidrs = ["10.0.3.0/24", "10.0.4.0/24"]
endpoints = ["com.amazonaws.us-west-2.s3", "com.amazonaws.us-west-2.dynamodb"]
endpoints_private_dns_enabled = [true, false]
endpoints_security_group_ids = [["sg-12345678"], ["sg-87654321"]]
endpoints_subnet_ids = [["subnet-1234abcd"], ["subnet-abcd1234"]]
endpoints_type = ["Gateway", "Interface"]
}
region
: AWS regioncidr_block
: CIDR block for the VPCenable_dns_support
: Enable DNS support in the VPCenable_dns_hostnames
: Enable DNS hostnames in the VPCinstance_tenancy
: Tenancy option for instances launched into the VPCvpc_name
: Name of the VPCtags
: A map of tags to add to all resourcesendpoints
: List of VPC endpointsendpoints_private_dns_enabled
: List of private DNS enabled for endpointsendpoints_security_group_ids
: List of security group IDs for endpointsendpoints_subnet_ids
: List of subnet IDs for endpointsendpoints_type
: List of endpoint typescreate_subnets
: Flag to create subnets automaticallycreate_internet_gateway
: Flag to create an Internet Gatewaycreate_nat_gateway
: Flag to create NAT Gatewaypublic_subnet_cidrs
: List of public subnet CIDR blocks if manually creating subnetsprivate_subnet_cidrs
: List of private subnet CIDR blocks if manually creating subnets
vpc_id
: The ID of the VPCvpc_arn
: The ARN of the VPCvpc_cidr_block
: The CIDR block of the VPCvpc_default_network_acl_id
: The ID of the default network ACLvpc_default_route_table_id
: The ID of the default route tablevpc_default_security_group_id
: The ID of the default security groupvpc_main_route_table_id
: The ID of the main route tablepublic_subnet_ids
: The IDs of the public subnetspublic_subnet_cidr_blocks
: The CIDR blocks of the public subnetsprivate_subnet_ids
: The IDs of the private subnetsprivate_subnet_cidr_blocks
: The CIDR blocks of the private subnetsinternet_gateway_id
: The ID of the Internet Gatewaynat_gateway_ids
: The IDs of the NAT Gatewaysnat_gateway_ips
: The Elastic IPs of the NAT Gatewayspublic_route_table_id
: The ID of the public route tableprivate_route_table_id
: The ID of the private route tablevpc_endpoints
: The IDs of the VPC endpoints