-
Notifications
You must be signed in to change notification settings - Fork 0
/
vpc_endpoints.tf
67 lines (56 loc) · 1.68 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
# Create VPC Endpoints For Session Manager
resource "aws_security_group" "east_ssm_sg" {
name = "ssm-sg"
vpc_id = aws_vpc.vpc_us_east.id
ingress {
description = "HTTPS from VPC"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [aws_vpc.vpc_us_east.cidr_block]
}
}
resource "aws_security_group" "west_ssm_sg" {
name = "ssm-sg"
vpc_id = aws_vpc.vpc_us_west.id
provider = aws.us-west
ingress {
description = "HTTPS from VPC"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [aws_vpc.vpc_us_west.cidr_block]
}
}
locals {
endpoints = {
"endpoint-ssm" = {
name = "ssm"
},
"endpoint-ssmm-essages" = {
name = "ssmmessages"
},
"endpoint-ec2-messages" = {
name = "ec2messages"
}
}
}
resource "aws_vpc_endpoint" "east_endpoints" {
vpc_id = aws_vpc.vpc_us_east.id
subnet_ids = [aws_subnet.subnet_us_east.id]
for_each = local.endpoints
vpc_endpoint_type = "Interface"
service_name = "com.amazonaws.us-east-1.${each.value.name}"
security_group_ids = [aws_security_group.east_ssm_sg.id]
private_dns_enabled = true # enabling DNS resolution allows to make requests to the service using its default DNS hostname
}
resource "aws_vpc_endpoint" "west_endpoints" {
provider = aws.us-west
vpc_id = aws_vpc.vpc_us_west.id
subnet_ids = [aws_subnet.subnet_us_west.id]
for_each = local.endpoints
vpc_endpoint_type = "Interface"
service_name = "com.amazonaws.us-west-1.${each.value.name}"
security_group_ids = [aws_security_group.west_ssm_sg.id]
private_dns_enabled = true
}