-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaws-vpc.tf
100 lines (85 loc) · 2.27 KB
/
aws-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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
module "label_network" {
source = "bendoerr-terraform-modules/label/null"
version = "0.4.2"
context = var.context
name = "ntwrk"
}
locals {
network_nameless_tags = { for k, v in module.label_network.tags : k => v if k != "Name" }
}
module "vpc_default" {
source = "terraform-aws-modules/vpc/aws"
version = "5.13.0"
create_vpc = true
name = module.label_network.id
tags = local.network_nameless_tags
cidr = var.network.cidr
azs = var.network.subnets.*.az
public_subnets = var.network.subnets.*.public
private_subnets = var.network.enable_private ? var.network.subnets.*.private : []
public_subnet_suffix = "public"
private_subnet_suffix = "private"
# Disable Private Subnet NAT Gateway unless it's needed
# NAT Gateways are expensive, between the need for an EIP, the base cost and
# per GB cost of data, disable them until the private networks actually need
# to use them.
enable_nat_gateway = var.network.enable_nat
single_nat_gateway = var.network.one_nat
one_nat_gateway_per_az = true
enable_dns_hostnames = true
enable_ipv6 = false
public_dedicated_network_acl = false
private_dedicated_network_acl = false
public_inbound_acl_rules = [
{
rule_number = 100
rule_action = "allow"
from_port = 0
to_port = 0
protocol = "-1"
cidr_block = "0.0.0.0/0"
},
]
public_outbound_acl_rules = [
{
rule_number = 100
rule_action = "allow"
from_port = 0
to_port = 0
protocol = "-1"
cidr_block = "0.0.0.0/0"
},
]
private_inbound_acl_rules = [
{
rule_number = 100
rule_action = "allow"
from_port = 0
to_port = 0
protocol = "-1"
cidr_block = var.network.cidr
},
]
private_outbound_acl_rules = [
{
rule_number = 100
rule_action = "allow"
from_port = 0
to_port = 0
protocol = "-1"
cidr_block = var.network.cidr
},
]
}
output "vpc_id" {
value = module.vpc_default.vpc_id
}
output "vpc_azs" {
value = module.vpc_default.azs
}
output "vpc_public_subnet_ids" {
value = module.vpc_default.public_subnets
}
output "vpc_private_subnet_ids" {
value = module.vpc_default.private_subnets
}