-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmgmt_subnet.tf
50 lines (41 loc) · 1.11 KB
/
mgmt_subnet.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
resource "aws_subnet" "mgmt" {
vpc_id = aws_vpc.valtix_svpc.id
count = length(var.zones)
cidr_block = cidrsubnet(var.vpc_cidr, var.vpc_subnet_bits, (count.index * 3) + 2)
availability_zone = var.zones[count.index]
tags = {
Name = "${var.prefix}_${var.zones[count.index]}_mgmt"
prefix = var.prefix
}
}
resource "aws_route_table" "mgmt" {
vpc_id = aws_vpc.valtix_svpc.id
count = length(var.zones)
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.gw.id
}
tags = {
Name = "${var.prefix}_${var.zones[count.index]}_mgmt"
prefix = var.prefix
}
}
resource "aws_route_table_association" "mgmt" {
count = length(var.zones)
subnet_id = aws_subnet.mgmt[count.index].id
route_table_id = aws_route_table.mgmt[count.index].id
}
resource "aws_security_group" "mgmt" {
name = "${var.prefix}_mgmt"
vpc_id = aws_vpc.valtix_svpc.id
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "${var.prefix}_mgmt"
prefix = var.prefix
}
}