A terraform module to create an AWS VPC.
For security reasons:
- Default RTB is not associated with any VPC subnet.
- Default ACL DENY ALL.
- Default SG DENY ALL.
name
- AWS VPC namedomain_name
(optional) - Domain Name used in the DHCP options. Will be used to complete unqualified DNS hostnames within the VPC. Default value""
.cidr_block
(optional) - VPC CIDR Block. Default value10.0.0.0/16
.ipv6_cidr_block
(optional) - Enable IPv6 in the VPC. Default valuefalse
.ipv6_private_egress
(optional) - Enable IPv6 Egress Gateway for private subnets. Default valuefalse
.tenancy
(optional) - Force the default hardware tenancy of any instance you launch in the VPC. Default valuedefault
.enable_dns_support
(optional) - Indicates whether the DNS resolution is supported for the VPC. Default valuetrue
.enable_dns_hostnames
(optional) - Indicates whether the instances launched in the VPC get public DNS hostnames. Default valuetrue
.domain_name_servers
(optional) - DNS servers that will resolve hostnames. Default valueAmazonProvidedDNS
.AZs
(optional) - Number of AWS AZs to be used (a,b,c,d,e).enable_vpc_flow_logs
- Enable AWS VPC Flow Logs for this VPC. Default valuefalse
.enable_nat_gw
- Create one NAT Gateway for each AZs. Default valuetrue
.allow_all_ACL
- Add generic ACL rules to allow ALL traffic.only_public
- Create only public subnets, not private subnets.
Adding IPv6 support to an already existing VPC with only IPv4 is not supported. You will have to destroy it and create a new VPC.
module "vpc" {
source = "github.com/KoeSystems/terraform-aws-vpc?ref=v0.5.0"
name = "vpc01"
}
Enable VPC Flow Logs
module "vpc" {
source = "github.com/KoeSystems/terraform-aws-vpc"
name = "vpc01"
vpc_flow_logs = true
}
Enable IPv6
module "vpc" {
source = "github.com/KoeSystems/terraform-aws-vpc"
name = "vpc01"
ipv6_cidr_block = true
}
Production ready VPC
module "vpc" {
source = "github.com/KoeSystems/terraform-aws-vpc?ref=v0.5.0"
name = "vpc01"
AZs = "a,b,c"
cidr_block = "10.0.0.0/16"
only_public = false
enable_nat_gw = true
allow_all_ACL = true
enable_vpc_flow_logs = true
domain_name = "vpc01.example.com"
enable_dns_support = true
enable_dns_hostnames = true
}
The terraform module will create a NAT Gateway for each AZs (by default = 3), you can reduce costs by reducing the number of AZs. Also terraform will configure VPC Flow Logs by default to be able to trace all the network traffic within the VPC, this will generate some costs in AWS CloudWatch Logs. Two Route53 will be created, one public and another private attached to the VPC.
Originally created and maintained by Koe
MIT License. See LICENSE for full details.