Skip to content

Commit 024fbc0

Browse files
authored
fix: Declare data resource only for requested VPC endpoints (#800)
1 parent 41da688 commit 024fbc0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

modules/vpc-endpoints/main.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
# Endpoint(s)
33
################################################################################
44

5+
locals {
6+
endpoints = { for k, v in var.endpoints : k => v if var.create && try(v.create, true) }
7+
}
8+
59
data "aws_vpc_endpoint_service" "this" {
6-
for_each = { for k, v in var.endpoints : k => v if var.create }
10+
for_each = local.endpoints
711

812
service = lookup(each.value, "service", null)
913
service_name = lookup(each.value, "service_name", null)
@@ -15,7 +19,7 @@ data "aws_vpc_endpoint_service" "this" {
1519
}
1620

1721
resource "aws_vpc_endpoint" "this" {
18-
for_each = { for k, v in var.endpoints : k => v if var.create && try(v.create, true) }
22+
for_each = local.endpoints
1923

2024
vpc_id = var.vpc_id
2125
service_name = data.aws_vpc_endpoint_service.this[each.key].service_name

0 commit comments

Comments
 (0)