This repository was archived by the owner on Nov 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdata-egress_sg.tf
More file actions
74 lines (67 loc) · 2.93 KB
/
Copy pathdata-egress_sg.tf
File metadata and controls
74 lines (67 loc) · 2.93 KB
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
resource "aws_security_group" "data_egress_service" {
name = "data_egress_service"
description = "Control access to and from data egress service"
vpc_id = data.terraform_remote_state.aws_sdx.outputs.vpc.vpc.id
tags = merge(
local.common_tags,
{
Name = "data_egress_service"
}
)
}
resource "aws_security_group_rule" "service_ingress" {
for_each = { for security_group_rule in local.service_security_group_rules : security_group_rule.name => security_group_rule }
description = "Allow inbound requests from ${each.value.name}"
type = "ingress"
from_port = each.value.port
to_port = each.value.port
protocol = "tcp"
security_group_id = each.value.destination
source_security_group_id = aws_security_group.data_egress_service.id
}
resource "aws_security_group_rule" "service_egress" {
for_each = { for security_group_rule in local.service_security_group_rules : security_group_rule.name => security_group_rule }
description = "Allow outbound requests to ${each.value.name}"
type = "egress"
from_port = each.value.port
to_port = each.value.port
protocol = "tcp"
source_security_group_id = each.value.destination
security_group_id = aws_security_group.data_egress_service.id
}
resource "aws_security_group_rule" "data_egress_service_s3_https" {
description = "Access to S3 https"
type = "egress"
prefix_list_ids = [data.terraform_remote_state.aws_sdx.outputs.vpc.prefix_list_ids.s3]
protocol = "tcp"
from_port = 443
to_port = 443
security_group_id = aws_security_group.data_egress_service.id
}
resource "aws_security_group_rule" "data_egress_service_s3_http" {
description = "Access to S3 http"
type = "egress"
prefix_list_ids = [data.terraform_remote_state.aws_sdx.outputs.vpc.prefix_list_ids.s3]
protocol = "tcp"
from_port = 80
to_port = 80
security_group_id = aws_security_group.data_egress_service.id
}
resource "aws_security_group_rule" "data_egress_service_dynamodb" {
description = "Allow data egress server to reach DynamoDB"
type = "egress"
prefix_list_ids = [data.terraform_remote_state.aws_sdx.outputs.vpc.prefix_list_ids.dynamodb]
protocol = "tcp"
from_port = 443
to_port = 443
security_group_id = aws_security_group.data_egress_service.id
}
resource "aws_security_group_rule" "data_egress_dks" {
description = "Allow outbound requests to DKS"
type = "egress"
from_port = 8443
to_port = 8443
protocol = "tcp"
cidr_blocks = data.terraform_remote_state.crypto.outputs.dks_subnet.cidr_blocks
security_group_id = aws_security_group.data_egress_service.id
}