Skip to content

Commit 8fededb

Browse files
authored
Merge pull request #213 from michieldhadamus/ecr-endpoints
Added option to create ECR api and dkr endpoints
2 parents bd089fb + 176a596 commit 8fededb

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

main.tf

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,46 @@ 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+
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+
370410
############################
371411
# VPC Endpoint for DynamoDB
372412
############################

variables.tf

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,46 @@ 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_subnet_ids" {
187+
description = "The ID of one or more subnets in which to create a network interface for ECR api endpoint. If omitted, private subnets will be used."
188+
default = []
189+
}
190+
191+
variable "ecr_api_endpoint_private_dns_enabled" {
192+
description = "Whether or not to associate a private hosted zone with the specified VPC for ECR API endpoint"
193+
default = false
194+
}
195+
196+
variable "ecr_api_endpoint_security_group_ids" {
197+
description = "The ID of one or more security groups to associate with the network interface for ECR API endpoint"
198+
default = []
199+
}
200+
201+
variable "enable_ecr_dkr_endpoint" {
202+
description = "Should be true if you want to provision an ecr dkr endpoint to the VPC"
203+
default = false
204+
}
205+
206+
variable "ecr_dkr_endpoint_subnet_ids" {
207+
description = "The ID of one or more subnets in which to create a network interface for ECR dkr endpoint. If omitted, private subnets will be used."
208+
default = []
209+
}
210+
211+
variable "ecr_dkr_endpoint_private_dns_enabled" {
212+
description = "Whether or not to associate a private hosted zone with the specified VPC for ECR DKR endpoint"
213+
default = false
214+
}
215+
216+
variable "ecr_dkr_endpoint_security_group_ids" {
217+
description = "The ID of one or more security groups to associate with the network interface for ECR DKR endpoint"
218+
default = []
219+
}
220+
181221
variable "enable_ssm_endpoint" {
182222
description = "Should be true if you want to provision an SSM endpoint to the VPC"
183223
default = false

0 commit comments

Comments
 (0)