@@ -159,12 +159,14 @@ resource "aws_route_table_association" "public" {
159159}
160160
161161resource "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
167168resource "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" {
173175resource "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
180182resource "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