-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpc.tf
39 lines (30 loc) · 956 Bytes
/
vpc.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "3.14.0"
name = "${local.project}-vpc-${var.environment}"
cidr = "10.0.0.0/16"
azs = ["${var.aws_region}a", "${var.aws_region}b", "${var.aws_region}c"]
private_subnets = ["10.0.1.0/24"]
public_subnets = ["10.0.101.0/24", "10.0.102.0/24"]
enable_nat_gateway = true
enable_vpn_gateway = true
enable_dns_hostnames = true
enable_dns_support = true
tags = {
Terraform = "true"
}
}
data "aws_availability_zones" "available" {}
resource "aws_route" "internet_access" {
route_table_id = module.vpc.vpc_main_route_table_id
destination_cidr_block = "0.0.0.0/0"
gateway_id = module.vpc.igw_id
}
resource "aws_route_table" "private" {
count = length(data.aws_availability_zones.available.names)
vpc_id = module.vpc.vpc_id
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = module.vpc.natgw_ids[0]
}
}