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
- Host: GitHub
- URL: https://github.com/willfarrell/terraform-vpc-module
- Owner: willfarrell
- License: mit
- Created: 2019-06-16T23:03:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-02T03:02:50.000Z (over 1 year ago)
- Last Synced: 2025-01-19T13:27:11.910Z (about 1 year ago)
- Language: HCL
- Size: 94.7 KB
- Stars: 1
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: docs/README.md
- License: LICENSE
Awesome Lists containing this project
README
# VPC
Creates a VPC over two AZ w/ NAT in each AZ.
## 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
