forked from tuier/tfm-vpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprivate.tf
59 lines (47 loc) · 1.56 KB
/
private.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
# private network
resource "aws_subnet" "private" {
count = "${var.azs_count}"
#count = "${length(compact(split(",",lookup(var.azs_name, var.region))))}"
vpc_id = "${aws_vpc.main.id}"
cidr_block = "10.${var.network_number}.1${count.index}.0/24"
availability_zone = "${var.region}${element(split(",",lookup(var.azs_name, var.region)), count.index)}"
tags {
Name = "${var.cluster_name}_private-${element(split(",",lookup(var.azs_name, var.region)), count.index)}"
cluster = "${var.cluster_name}"
product = "${var.tag_product}"
purpose = "${var.tag_purpose}"
builder = "terraform"
}
lifecycle {
create_before_destroy = true
}
}
resource "aws_route_table" "private" {
count = "${var.azs_count}"
# count = "${length(aws_subnet.private.*.id)}"
vpc_id = "${aws_vpc.main.id}"
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = "${element(aws_nat_gateway.gw.*.id, count.index)}"
}
tags {
Name = "${var.cluster_name}_private-${count.index}"
cluster = "${var.cluster_name}"
product = "${var.tag_product}"
purpose = "${var.tag_purpose}"
builder = "terraform"
}
lifecycle {
create_before_destroy = true
ignore_changes = ["route"]
}
}
resource "aws_route_table_association" "private" {
count = "${var.azs_count}"
# count = "${length(aws_subnet.private.*.id)}"
subnet_id = "${element(aws_subnet.private.*.id,count.index)}"
route_table_id = "${element(aws_route_table.private.*.id,count.index)}"
lifecycle {
create_before_destroy = true
}
}