An open API service indexing awesome lists of open source software.

https://github.com/willfarrell/terraform-vpc-module

VPC w/ NATs
https://github.com/willfarrell/terraform-vpc-module

Last synced: 2 months ago
JSON representation

VPC w/ NATs

Awesome Lists containing this project

README

          

# VPC
Creates a VPC over two AZ w/ NAT in each AZ.


Module Diagram

## Features
- 1 region
- 2+ availability zones (AZ)
- 1 public, 1 private subnet per AZ
- 1 NAT per public subnet
- ACL - Allow http, https, dns, ephemeral ports, easy to extend

## Setup

### Module

```hcl-terraform
module "vpc" {
source = "git@github.com:willfarrell/terraform-vpc-module//vpc?ref=v0.0.1"
name = local.workspace["name"]
az_count = local.workspace["az_count"]
cidr_block = local.workspace["cidr_block"]
nat_type = local.workspace["nat_type"]
ami_account_id = data.terraform_remote_state.master.outputs.account_id
}
```

## Outputs
```hcl-terraform
output "nat_ips" {
value = module.vpc.public_ips
}

output "nat_billing_suggestion" {
value = module.vpc.billing_suggestion
}

# Output config information to SSM Paramstore for use from Serverless, Lambda or other components
resource "aws_ssm_parameter" "vpc_id" {
name = "/infrastructure/vpc/id"
description = "VPC ID"
type = "String"
value = module.vpc.id
}

resource "aws_ssm_parameter" "vpc_public_subnets" {
name = "/infrastructure/vpc/public_subnets"
description = "VPC public subnets"
type = "StringList"
value = join(",", module.vpc.public_subnet_ids)
}

resource "aws_ssm_parameter" "vpc_private_subnets" {
name = "/infrastructure/vpc/private_subnets"
description = "VPC private subnets"
type = "StringList"
value = join(",", module.vpc.private_subnet_ids)
}

resource "aws_ssm_parameter" "vpc_secuirty_group" {
name = "/infrastructure/vpc/security_group"
description = "VPC security group"
type = "String"
value = module.vpc.security_group_id
}
```

### Add Gateway Endpoints
```hcl-terraform
resource "aws_vpc_endpoint" "s3" {
vpc_id = module.vpc.id
service_name = "com.amazonaws.${local.workspace["region"]}.s3"
route_table_ids = module.vpc.private_route_table_ids
policy = <=2
`nat_type` | `instance` | `gateway`

## Known Issues:
- Unable to increase `az_count` when using a NAT instance

## Related
- https://github.com/terraform-aws-modules/terraform-aws-vpc

## TODO