-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathefs.tf
73 lines (67 loc) · 1.65 KB
/
efs.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
resource "aws_efs_file_system" "packages" {
creation_token = "pypi-packages"
tags = merge(
{
Name = "pypi-packages"
},
local.default_module_tags
)
}
resource "aws_efs_mount_target" "packages" {
for_each = toset(var.asg_subnets)
file_system_id = aws_efs_file_system.packages.id
subnet_id = each.key
security_groups = [
aws_security_group.efs.id
]
}
resource "aws_security_group" "efs" {
description = "Security group for pypiserver EFS volume"
name_prefix = var.dns_names[0]
vpc_id = data.aws_subnet.selected.vpc_id
tags = merge(
{
Name : "pypiserver EFS"
},
local.default_module_tags
)
}
resource "aws_vpc_security_group_ingress_rule" "efs" {
description = "Allow NFS traffic to EFS volume"
security_group_id = aws_security_group.efs.id
from_port = 2049
to_port = 2049
ip_protocol = "tcp"
cidr_ipv4 = data.aws_vpc.selected.cidr_block
tags = merge(
{
Name = "NFS traffic"
},
local.default_module_tags
)
}
resource "aws_vpc_security_group_ingress_rule" "efs_icmp" {
description = "Allow all ICMP traffic"
security_group_id = aws_security_group.efs.id
from_port = -1
to_port = -1
ip_protocol = "icmp"
cidr_ipv4 = "0.0.0.0/0"
tags = merge(
{
Name = "ICMP traffic"
},
local.default_module_tags
)
}
resource "aws_vpc_security_group_egress_rule" "efs" {
security_group_id = aws_security_group.efs.id
ip_protocol = "-1"
cidr_ipv4 = "0.0.0.0/0"
tags = merge(
{
Name = "EFS outgoing traffic"
},
local.default_module_tags
)
}