-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpc-endpoints.tf
80 lines (66 loc) · 2.5 KB
/
vpc-endpoints.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
resource "aws_security_group" "vpc_endpoints" {
name_prefix = "vpc-endpoints/${local.block_name}"
vpc_id = module.network.vpc_id
tags = local.tags
description = "Security group attached to every VPC endpoint"
lifecycle {
create_before_destroy = true
}
}
resource "aws_security_group_rule" "allow_inside" {
security_group_id = aws_security_group.vpc_endpoints.id
type = "ingress"
protocol = "tcp"
from_port = 0
to_port = 65535
cidr_blocks = [var.cidr]
description = "Enable VPC endpoints to access any port for any device on the network"
}
data "aws_vpc_endpoint_service" "ecr_api" {
service = "ecr.api"
}
resource "aws_vpc_endpoint" "ecr_api" {
vpc_id = module.network.vpc_id
service_name = data.aws_vpc_endpoint_service.ecr_api.service_name
vpc_endpoint_type = "Interface"
security_group_ids = [aws_security_group.vpc_endpoints.id]
subnet_ids = module.network.private_subnets
tags = local.tags
count = var.enable_vpc_endpoints ? 1 : 0
}
data "aws_vpc_endpoint_service" "ecr_dkr" {
service = "ecr.dkr"
}
resource "aws_vpc_endpoint" "ecr_dkr" {
vpc_id = module.network.vpc_id
service_name = data.aws_vpc_endpoint_service.ecr_dkr.service_name
vpc_endpoint_type = "Interface"
security_group_ids = [aws_security_group.vpc_endpoints.id]
subnet_ids = module.network.private_subnets
tags = local.tags
count = var.enable_vpc_endpoints ? 1 : 0
}
data "aws_vpc_endpoint_service" "secretsmanager" {
service = "secretsmanager"
}
resource "aws_vpc_endpoint" "secretsmanager" {
vpc_id = module.network.vpc_id
service_name = data.aws_vpc_endpoint_service.secretsmanager.service_name
vpc_endpoint_type = "Interface"
security_group_ids = [aws_security_group.vpc_endpoints.id]
subnet_ids = module.network.private_subnets
tags = local.tags
count = var.enable_vpc_endpoints ? 1 : 0
}
data "aws_vpc_endpoint_service" "kms" {
service = "kms"
}
resource "aws_vpc_endpoint" "kms" {
vpc_id = module.network.vpc_id
service_name = data.aws_vpc_endpoint_service.kms.service_name
vpc_endpoint_type = "Interface"
security_group_ids = [aws_security_group.vpc_endpoints.id]
subnet_ids = module.network.private_subnets
tags = local.tags
count = var.enable_vpc_endpoints ? 1 : 0
}