@@ -367,6 +367,46 @@ resource "aws_vpc_endpoint_route_table_association" "public_s3" {
367
367
route_table_id = " ${ aws_route_table . public . id } "
368
368
}
369
369
370
+ # #########################
371
+ # VPC Endpoint for ECR API
372
+ # #########################
373
+ data "aws_vpc_endpoint_service" "ecr_api" {
374
+ count = " ${ var . create_vpc && var . enable_ecr_api_endpoint ? 1 : 0 } "
375
+
376
+ service = " ecr.api"
377
+ }
378
+
379
+ resource "aws_vpc_endpoint" "ecr_api" {
380
+ count = " ${ var . create_vpc && var . enable_ecr_api_endpoint ? 1 : 0 } "
381
+
382
+ vpc_endpoint_type = " Interface"
383
+ vpc_id = " ${ local . vpc_id } "
384
+ security_group_ids = [" ${ var . ecr_api_endpoint_security_group_ids } " ]
385
+ subnet_ids = [" ${ coalescelist (var. ecr_api_endpoint_subnet_ids , aws_subnet. private . * . id )} " ]
386
+ service_name = " ${ data . aws_vpc_endpoint_service . ecr_api . service_name } "
387
+ private_dns_enabled = " ${ var . ecr_api_endpoint_private_dns_enabled } "
388
+ }
389
+
390
+ # #########################
391
+ # VPC Endpoint for ECR DKR
392
+ # #########################
393
+ data "aws_vpc_endpoint_service" "ecr_dkr" {
394
+ count = " ${ var . create_vpc && var . enable_ecr_dkr_endpoint ? 1 : 0 } "
395
+
396
+ service = " ecr.dkr"
397
+ }
398
+
399
+ resource "aws_vpc_endpoint" "ecr_dkr" {
400
+ count = " ${ var . create_vpc && var . enable_ecr_dkr_endpoint ? 1 : 0 } "
401
+
402
+ vpc_endpoint_type = " Interface"
403
+ vpc_id = " ${ local . vpc_id } "
404
+ security_group_ids = [" ${ var . ecr_dkr_endpoint_security_group_ids } " ]
405
+ subnet_ids = [" ${ coalescelist (var. ecr_dkr_endpoint_subnet_ids , aws_subnet. private . * . id )} " ]
406
+ service_name = " ${ data . aws_vpc_endpoint_service . ecr_dkr . service_name } "
407
+ private_dns_enabled = " ${ var . ecr_dkr_endpoint_private_dns_enabled } "
408
+ }
409
+
370
410
# ###########################
371
411
# VPC Endpoint for DynamoDB
372
412
# ###########################
0 commit comments