Skip to content

Commit 9296082

Browse files
committed
Don't create dynamodb/s3 vpc-e if existing vpc is provided
1 parent af8b793 commit 9296082

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

rift_compute/vpc.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,14 @@ resource "aws_route_table_association" "public" {
159159
}
160160

161161
resource "aws_vpc_endpoint" "dynamodb" {
162+
count = local.is_existing_vpc ? 0 : 1
162163
vpc_id = local.vpc_id
163164
service_name = format("com.amazonaws.%s.dynamodb", data.aws_region.current.name)
164165
route_table_ids = local.is_existing_vpc ? null : values(aws_route_table.private)[*].id
165166
}
166167

167168
resource "aws_vpc_endpoint" "s3" {
169+
count = local.is_existing_vpc ? 0 : 1
168170
vpc_id = local.vpc_id
169171
service_name = format("com.amazonaws.%s.s3", data.aws_region.current.name)
170172
route_table_ids = local.is_existing_vpc ? null : values(aws_route_table.private)[*].id
@@ -173,14 +175,14 @@ resource "aws_vpc_endpoint" "s3" {
173175
resource "aws_vpc_endpoint_route_table_association" "dynamodb" {
174176
for_each = local.is_existing_vpc || length(aws_route_table.private) == 0 ? {} : aws_route_table.private
175177
# only create if module manages route tables
176-
vpc_endpoint_id = aws_vpc_endpoint.dynamodb.id
178+
vpc_endpoint_id = aws_vpc_endpoint.dynamodb[0].id
177179
route_table_id = each.value.id
178180
}
179181

180182
resource "aws_vpc_endpoint_route_table_association" "s3" {
181183
for_each = local.is_existing_vpc || length(aws_route_table.private) == 0 ? {} : aws_route_table.private
182184
# only create if module manages route tables
183-
vpc_endpoint_id = aws_vpc_endpoint.s3.id
185+
vpc_endpoint_id = aws_vpc_endpoint.s3[0].id
184186
route_table_id = each.value.id
185187
}
186188

0 commit comments

Comments
 (0)