-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpc-endpoints.tf
82 lines (67 loc) · 3.08 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
81
82
###############################################################################
# VPC endpoints module: https://github.com/terraform-aws-modules/terraform-aws-vpc.git
###############################################################################
module "vpc_endpoints" {
#############################################################################
# VPC endpoints settings
#############################################################################
source = "terraform-aws-modules/vpc/aws//modules/vpc-endpoints"
version = "~> 5.1.0"
#############################################################################
# VPC endpoints
#############################################################################
vpc_id = module.vpc.vpc_id
security_group_ids = [module.vpc_endpoints_sg.security_group_id]
subnet_ids = module.vpc.private_subnets
tags = local.resource_tags
endpoints = merge({
s3 = {
service = "s3"
service_type = "Gateway"
route_table_ids = module.vpc.private_route_table_ids
tags = {
Name = "${local.name}-vpc-s3"
}
}
},
{ for service in toset(["autoscaling", "ecr.api", "ecr.dkr", "ec2", "ec2messages", "elasticloadbalancing", "sts", "kms", "logs", "ssm", "ssmmessages"]) :
replace(service, ".", "_") =>
{
service = service
subnet_ids = module.vpc.private_subnets
private_dns_enabled = true
tags = { Name = "${local.name}-${service}" }
}
})
}
###############################################################################
# SG module: https://github.com/terraform-aws-modules/terraform-aws-security-group.git
###############################################################################
module "vpc_endpoints_sg" {
#############################################################################
# Security group settings
#############################################################################
source = "terraform-aws-modules/security-group/aws"
version = "~> 5.1.0"
#############################################################################
# Security group
#############################################################################
name = "${local.name}-vpc-endpoints-sg"
description = "Security group for VPC endpoint access"
vpc_id = module.vpc.vpc_id
tags = local.resource_tags
#############################################################################
# Ingress
#############################################################################
ingress_with_cidr_blocks = [
{
rule = "https-443-tcp"
description = "VPC CIDR HTTPS"
cidr_blocks = join(",", module.vpc.private_subnets_cidr_blocks)
},
]
#############################################################################
# Egress
#############################################################################
egress_with_cidr_blocks = var.egress_with_cidr_blocks
}