Skip to content

Commit dda722c

Browse files
author
Calvin French-Owen
authored
Merge pull request segmentio#45 from segmentio/split-routes
vpc: split routes
2 parents 4f68487 + c421134 commit dda722c

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

vpc/main.tf

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,30 +97,33 @@ resource "aws_subnet" "external" {
9797
resource "aws_route_table" "external" {
9898
vpc_id = "${aws_vpc.main.id}"
9999

100-
route {
101-
cidr_block = "0.0.0.0/0"
102-
gateway_id = "${aws_internet_gateway.main.id}"
103-
}
104-
105100
tags {
106101
Name = "${var.name}-external-001"
107102
}
108103
}
109104

105+
resource "aws_route" "external" {
106+
route_table_id = "${aws_route_table.external.id}"
107+
destination_cidr_block = "0.0.0.0/0"
108+
gateway_id = "${aws_internet_gateway.main.id}"
109+
}
110+
110111
resource "aws_route_table" "internal" {
111112
count = "${length(compact(split(",", var.internal_subnets)))}"
112113
vpc_id = "${aws_vpc.main.id}"
113114

114-
route {
115-
cidr_block = "0.0.0.0/0"
116-
nat_gateway_id = "${element(aws_nat_gateway.main.*.id, count.index)}"
117-
}
118-
119115
tags {
120116
Name = "${var.name}-${format("internal-%03d", count.index+1)}"
121117
}
122118
}
123119

120+
resource "aws_route" "internal" {
121+
count = "${length(compact(split(",", var.internal_subnets)))}"
122+
route_table_id = "${element(aws_route_table.internal.*.id, count.index)}"
123+
destination_cidr_block = "0.0.0.0/0"
124+
nat_gateway_id = "${element(aws_nat_gateway.main.*.id, count.index)}"
125+
}
126+
124127
/**
125128
* Route associations
126129
*/

0 commit comments

Comments
 (0)