-
Notifications
You must be signed in to change notification settings - Fork 8
/
public.tf
55 lines (45 loc) · 1.41 KB
/
public.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
# public network
resource "aws_subnet" "public" {
count = "${var.azs_count}"
#count = "${length(split(",", lookup(var.azs_name, var.region)))}"
vpc_id = "${aws_vpc.main.id}"
cidr_block = "10.${var.network_number}.${count.index}.0/24"
availability_zone = "${var.region}${element(split(",", lookup(var.azs_name, var.region)), count.index)}"
tags {
Name = "${var.cluster_name}_public-${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" "public" {
vpc_id = "${aws_vpc.main.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.default.id}"
}
tags {
Name = "${var.cluster_name}_public"
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" "public" {
count = "${var.azs_count}"
# count = "${length(aws_subnet.public.*.id)}"
subnet_id = "${element(aws_subnet.public.*.id,count.index)}"
route_table_id = "${aws_route_table.public.id}"
lifecycle {
create_before_destroy = true
}
}