-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpc_endpoints.tf
67 lines (61 loc) · 2.66 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
###########
## https://docs.aws.amazon.com/systems-manager/latest/userguide/setup-create-vpc.html#sysman-setting-up-vpc-create
###########
resource "aws_security_group" "vpce_sg" {
name = "vpc-endpoints-sg"
vpc_id = aws_vpc.bastion_project_vpc.id
}
resource "aws_security_group_rule" "vpce_sg_rule_ingress" {
type = "ingress"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["10.0.0.0/16"]
security_group_id = aws_security_group.vpce_sg.id
}
resource "aws_security_group_rule" "vpce_sg_rule_egress" {
type = "egress"
from_port = 443
to_port = 443
protocol = "tcp"
source_security_group_id = aws_security_group.bastion_sg.id
security_group_id = aws_security_group.vpce_sg.id
}
resource "aws_vpc_endpoint" "rds_endpoint" {
vpc_id = aws_vpc.bastion_project_vpc.id
vpc_endpoint_type = "Interface"
service_name = "com.amazonaws.${var.region}.rds"
security_group_ids = [aws_security_group.vpce_sg.id]
subnet_ids = [aws_subnet.bastion_project_subnet_1.id, aws_subnet.db_subnet_1.id, aws_subnet.db_subnet_2.id]
private_dns_enabled = true
}
resource "aws_vpc_endpoint" "ssm_endpoint" {
vpc_id = aws_vpc.bastion_project_vpc.id
vpc_endpoint_type = "Interface"
service_name = "com.amazonaws.${var.region}.ssm"
security_group_ids = [aws_security_group.vpce_sg.id]
subnet_ids = [aws_subnet.bastion_project_subnet_1.id, aws_subnet.db_subnet_1.id, aws_subnet.db_subnet_2.id]
private_dns_enabled = true
}
resource "aws_vpc_endpoint" "ssm_messages_endpoint" {
vpc_id = aws_vpc.bastion_project_vpc.id
vpc_endpoint_type = "Interface"
service_name = "com.amazonaws.${var.region}.ssmmessages"
security_group_ids = [aws_security_group.vpce_sg.id]
subnet_ids = [aws_subnet.bastion_project_subnet_1.id, aws_subnet.db_subnet_1.id, aws_subnet.db_subnet_2.id]
private_dns_enabled = true
}
resource "aws_vpc_endpoint" "ec2_messages_endpoint" {
vpc_id = aws_vpc.bastion_project_vpc.id
vpc_endpoint_type = "Interface"
service_name = "com.amazonaws.${var.region}.ec2messages"
security_group_ids = [aws_security_group.vpce_sg.id]
subnet_ids = [aws_subnet.bastion_project_subnet_1.id, aws_subnet.db_subnet_1.id, aws_subnet.db_subnet_2.id]
private_dns_enabled = true
}
resource "aws_vpc_endpoint" "s3_gateway_endpoint" {
vpc_id = aws_vpc.bastion_project_vpc.id
vpc_endpoint_type = "Gateway"
service_name = "com.amazonaws.${var.region}.s3"
route_table_ids = [aws_route_table.internal.id]
}