@@ -180,13 +180,33 @@ data "aws_security_group" "main" {
180180}
181181
182182resource "aws_vpc_endpoint" "s3" {
183+ count = data. aws_vpc_endpoint . s3 == null ? 1 : 0
183184 vpc_id = local. vpc . id
184185 service_name = " com.amazonaws.${ var . region } .s3"
185186 vpc_endpoint_type = " Gateway"
186187 route_table_ids = local. private_route_tables [* ]. id
187188 tags = merge ({ Name = " ${ var . name } -s3-endpoint" }, var. tags )
188189}
189190
191+ data "aws_vpc_endpoint" "s3" {
192+ vpc_id = local. vpc . id
193+ service_name = " com.amazonaws.${ var . region } .s3"
194+ }
195+
196+ /*
197+ # probably can just remove this block entirely - it adds route_table_associations between to data.aws_vpc_endpoint.s3
198+ # with local.private_route_tables (if local.private_route_tables were provided by variable, may be duplicative/overwrite existing associations)
199+ resource "aws_vpc_endpoint_route_table_association" "s3" {
200+ count = data.aws_vpc_endpoint.s3 != null ? length(local.private_route_tables) : 0
201+ #count = length(local.private_route_tables)
202+
203+ # this won't be created unless data.aws_vpc_endpoint.s3 exists, no need to refer to aws_vpc_endpoint.s3 resource here:
204+ #vpc_endpoint_id = length(aws_vpc_endpoint.s3) > 0 ? one(aws_vpc_endpoint.s3[*]).id : data.aws_vpc_endpoint.s3.id
205+ vpc_endpoint_id = data.aws_vpc_endpoint.s3.id
206+ route_table_id = local.private_route_tables[count.index].id
207+ }
208+ */
209+
190210resource "aws_vpc_endpoint" "ecr_api" {
191211 vpc_id = local. vpc . id
192212 service_name = " com.amazonaws.${ var . region } .ecr.api"
@@ -235,9 +255,21 @@ resource "aws_vpc_endpoint" "eks" {
235255 vpc_id = local. vpc . id
236256 service_name = " com.amazonaws.${ var . region } .eks"
237257 vpc_endpoint_type = " Interface"
238- private_dns_enabled = true
258+ private_dns_enabled = false
239259 security_group_ids = [local . aws_security_group . id ]
240260 # security_group_ids = local.aws_security_groups[*].id
241261 subnet_ids = local. private_subnets [* ]. id
242262 tags = merge ({ Name = " ${ var . name } -eks-endpoint" }, var. tags )
243263}
264+ /*
265+ resource "aws_vpc_endpoint" "eks_oidc" {
266+ vpc_id = local.vpc.id
267+ service_name = "com.amazonaws.${var.region}.eks.oidc"
268+ vpc_endpoint_type = "Interface"
269+ private_dns_enabled = true
270+ security_group_ids = [local.aws_security_group.id]
271+ #security_group_ids = local.aws_security_groups[*].id
272+ subnet_ids = local.private_subnets[*].id
273+ tags = merge({ Name = "${var.name}-eks-oidc-endpoint" }, var.tags)
274+ }
275+ */
0 commit comments