AWS Virtual Private Cloud (VPC) Terraform Module
Terraform module to provision VPC Resources
on AWS.
This module contains VPC Peering as sub-modules under modules
folder.
In order to create a VPC Peering connection, you need to create a requester VPC and a accepter VPC first.
Usage
Simple setup
Create a simple VPC with default configurations.
module "vpc" {
source = "app.terraform.io/ncodelibrary/vpc/aws"
version = "0.1.7"
multi_nat_gw = false
vpc_settings = {
application_subnets = ["10.10.16.0/22", "10.10.20.0/22"]
public_subnets = ["10.10.0.0/22", "10.10.4.0/22"]
dns_hostnames = true
data_subnets = []
dns_support = true
tenancy = "default"
cidr = "10.10.0.0/16"
}
identifier = "example"
region = "us-east-1"
tags = {
Owner = "sysops"
env = "dev"
}
}
For more details on a working example, please visit examples/simple
Advanced Setup
If you want to create VPC with enhanced configuration e.g VPC Flowlogs etc., you can use the module like this:
Create a S3 bucket for VPC Flowlogs
module "s3" {
source = "app.terraform.io/ncodelibrary/s3-bucket/aws"
version = "0.1.2"
identifier = "example-s3-bucket-for-flow-logs-123"
tags = {
Owner = "sysops"
env = "dev"
}
}
Create a VPC
module "vpc" {
source = "app.terraform.io/ncodelibrary/vpc/aws"
version = "0.1.7"
multi_nat_gw = true
s3_flow_log_bucket = module.s3.output.bucket.arn
flow_log_settings = {
log_destination_type = "s3"
enable_flow_log = true
traffic_type = "ALL"
}
vpc_settings = {
application_subnets = ["10.10.24.0/22", "10.10.28.0/22", "10.10.32.0/22"]
public_subnets = ["10.10.0.0/22", "10.10.4.0/22", "10.10.8.0/22"]
data_subnets = ["10.10.12.0/22", "10.10.16.0/22", "10.10.20.0/22"]
dns_hostnames = true
dns_support = true
tenancy = "default"
cidr = "10.10.0.0/16"
}
identifier = "example"
region = "us-east-1"
tags = {
Owner = "sysops"
env = "dev"
}
}
For more options refer to a working example at examples/advanced
Examples
Here are some working examples of using this module:
Requirements
Name | Version |
---|---|
terraform | >= 0.12 |
Providers
Name | Version |
---|---|
aws | n/a |
Modules
No modules.
Resources
Inputs
Name | Description | Type | Default | Required |
---|---|---|---|---|
allowed_cird_blocks_application | List of allowed CIDR blocks into application subnets via NACL | list(string) |
[] |
no |
allowed_cird_blocks_data | List of allowed CIDR blocks into data subnets via NACL | list(string) |
[] |
no |
append_workspace | Appends the terraform workspace at the end of resource names, |
bool |
true |
no |
create_private_endpoints | Set to true to create private endpoints | bool |
true |
no |
description | A description for the VPC | string |
"VPC created by terraform" |
no |
flow_log_settings | Map of VPC Flow Logs settings | object({ |
{ |
no |
identifier | Name of the VPC | string |
n/a | yes |
kubernetes_tagging | Set to true to enable kubernetes required tags for subnets | bool |
false |
no |
multi_nat_gw | Set to true to create a nat gateway per availability zone, symmetrical subnets are required for best performance, try to avoid different subnet count between layers | bool |
false |
no |
region | Region where the VPC will be deployed | string |
n/a | yes |
s3_flow_log_bucket | S3 bucket where flow logs will be sent | string |
"" |
no |
tags | Tags to be applied to the resource | map(any) |
{} |
no |
vpc_settings | Map of AWS VPC settings | object({ |
{ |
no |
Outputs
Name | Description |
---|---|
output | n/a |
Contributing
If you want to contribute to this repository check all the guidelines specified here before submitting a new PR.