Skip to content

Commit 33e8809

Browse files
author
Michiel Dhadamus
committed
Added option to create ECR api and dkr endpoints
1 parent 8e2f50e commit 33e8809

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

main.tf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,44 @@ resource "aws_vpc_endpoint_route_table_association" "public_s3" {
367367
route_table_id = "${aws_route_table.public.id}"
368368
}
369369

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+
service_name = "${data.aws_vpc_endpoint_service.ecr_api.service_name}"
386+
private_dns_enabled = "${var.ecr_api_endpoint_private_dns_enabled}"
387+
}
388+
389+
##########################
390+
# VPC Endpoint for ECR DKR
391+
##########################
392+
data "aws_vpc_endpoint_service" "ecr_dkr" {
393+
count = "${var.create_vpc && var.enable_ecr_dkr_endpoint ? 1 : 0}"
394+
395+
service = "ecr.dkr"
396+
}
397+
398+
resource "aws_vpc_endpoint" "ecr_dkr" {
399+
count = "${var.create_vpc && var.enable_ecr_dkr_endpoint ? 1 : 0}"
400+
401+
vpc_endpoint_type = "Interface"
402+
vpc_id = "${local.vpc_id}"
403+
security_group_ids = ["${var.ecr_dkr_endpoint_security_group_ids}"]
404+
service_name = "${data.aws_vpc_endpoint_service.ecr_dkr.service_name}"
405+
private_dns_enabled = "${var.ecr_dkr_endpoint_private_dns_enabled}"
406+
}
407+
370408
############################
371409
# VPC Endpoint for DynamoDB
372410
############################

variables.tf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,36 @@ variable "enable_s3_endpoint" {
178178
default = false
179179
}
180180

181+
variable "enable_ecr_api_endpoint" {
182+
description = "Should be true if you want to provision an ecr api endpoint to the VPC"
183+
default = false
184+
}
185+
186+
variable "ecr_api_endpoint_private_dns_enabled" {
187+
description = "Whether or not to associate a private hosted zone with the specified VPC for ECR API endpoint"
188+
default = false
189+
}
190+
191+
variable "ecr_api_endpoint_security_group_ids" {
192+
description = "The ID of one or more security groups to associate with the network interface for ECR API endpoint"
193+
default = []
194+
}
195+
196+
variable "enable_ecr_dkr_endpoint" {
197+
description = "Should be true if you want to provision an ecr dkr endpoint to the VPC"
198+
default = false
199+
}
200+
201+
variable "ecr_dkr_endpoint_private_dns_enabled" {
202+
description = "Whether or not to associate a private hosted zone with the specified VPC for ECR DKR endpoint"
203+
default = false
204+
}
205+
206+
variable "ecr_dkr_endpoint_security_group_ids" {
207+
description = "The ID of one or more security groups to associate with the network interface for ECR DKR endpoint"
208+
default = []
209+
}
210+
181211
variable "enable_ssm_endpoint" {
182212
description = "Should be true if you want to provision an SSM endpoint to the VPC"
183213
default = false

0 commit comments

Comments
 (0)