22# VPCE alternative to NAT Gateway
33# VPC Endpoint for ECR API
44resource "aws_vpc_endpoint" "ecr_api" {
5- vpc_id = var. vpc_id
6- service_name = " com.amazonaws.${ var . aws_region } .ecr.api"
7- vpc_endpoint_type = " Interface"
8- subnet_ids = var. private_subnet_ids
9- security_group_ids = [aws_security_group . vpc_endpoints . id ]
10- # allow for dns resolution
11- private_dns_enabled = true
12- tags = merge (var. tags , {
13- Name = " ${ var . prefix } -ecr-api-vpce"
14- })
5+ vpc_id = var. vpc_id
6+ service_name = " com.amazonaws.${ var . aws_region } .ecr.api"
7+ vpc_endpoint_type = " Interface"
8+ subnet_ids = var. private_subnet_ids
9+ security_group_ids = [aws_security_group . vpc_endpoints . id ]
10+ # allow for dns resolution
11+ private_dns_enabled = true
12+ tags = merge (var. tags , {
13+ Name = " ${ var . prefix } -ecr-api-vpce"
14+ })
1515}
1616
1717# VPC Endpoint for ECR Docker
1818resource "aws_vpc_endpoint" "ecr_docker" {
19- vpc_id = var. vpc_id
20- service_name = " com.amazonaws.${ var . aws_region } .ecr.dkr"
21- vpc_endpoint_type = " Interface"
22- subnet_ids = var. private_subnet_ids
23- security_group_ids = [aws_security_group . vpc_endpoints . id ]
24- # allow for dns resolution
25- private_dns_enabled = true
26- tags = merge (var. tags , {
27- Name = " ${ var . prefix } -ecr-dkr-vpce"
28- })
19+ vpc_id = var. vpc_id
20+ service_name = " com.amazonaws.${ var . aws_region } .ecr.dkr"
21+ vpc_endpoint_type = " Interface"
22+ subnet_ids = var. private_subnet_ids
23+ security_group_ids = [aws_security_group . vpc_endpoints . id ]
24+ # allow for dns resolution
25+ private_dns_enabled = true
26+ tags = merge (var. tags , {
27+ Name = " ${ var . prefix } -ecr-dkr-vpce"
28+ })
2929}
3030
3131# VPC Endpoint for CloudWatch Logs
3232resource "aws_vpc_endpoint" "cloudwatch_logs" {
33- vpc_id = var. vpc_id
34- service_name = " com.amazonaws.${ var . aws_region } .logs"
35- vpc_endpoint_type = " Interface"
36- subnet_ids = var. private_subnet_ids
37- security_group_ids = [aws_security_group . vpc_endpoints . id ]
38- private_dns_enabled = true
39- tags = merge (var. tags , {
40- Name = " ${ var . prefix } -cloudwatch-logs-vpce"
41- })
33+ vpc_id = var. vpc_id
34+ service_name = " com.amazonaws.${ var . aws_region } .logs"
35+ vpc_endpoint_type = " Interface"
36+ subnet_ids = var. private_subnet_ids
37+ security_group_ids = [aws_security_group . vpc_endpoints . id ]
38+ private_dns_enabled = true
39+ tags = merge (var. tags , {
40+ Name = " ${ var . prefix } -cloudwatch-logs-vpce"
41+ })
4242}
4343
4444# VPC Endpoint for S3 as ECR stores image layers in S3
4545resource "aws_vpc_endpoint" "s3" {
46- vpc_id = var. vpc_id
47- service_name = " com.amazonaws.${ var . aws_region } .s3"
48- vpc_endpoint_type = " Gateway"
49- route_table_ids = var. route_table_ids
50- tags = merge (var. tags , {
51- Name = " ${ var . prefix } -s3-vpce"
52- })
46+ vpc_id = var. vpc_id
47+ service_name = " com.amazonaws.${ var . aws_region } .s3"
48+ vpc_endpoint_type = " Gateway"
49+ route_table_ids = var. route_table_ids
50+ tags = merge (var. tags , {
51+ Name = " ${ var . prefix } -s3-vpce"
52+ })
5353}
5454
5555# Security group for VPC endpoints
@@ -59,10 +59,10 @@ resource "aws_security_group" "vpc_endpoints" {
5959 vpc_id = var. vpc_id
6060
6161 ingress {
62- from_port = 443
63- to_port = 443
64- protocol = " tcp"
65- security_groups = [var . ecs_sg_id ]
62+ from_port = 443
63+ to_port = 443
64+ protocol = " tcp"
65+ security_groups = [var . ecs_sg_id ]
6666 }
6767
6868 egress {
0 commit comments