-
Notifications
You must be signed in to change notification settings - Fork 0
/
efs.tf
55 lines (47 loc) · 1.32 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
locals {
security_group_name = var.security_group_name != null ? var.security_group_name : var.name
}
resource "aws_efs_file_system" "this" {
creation_token = var.name
tags = merge(
local.tags,
{
Name = var.name
}
)
}
resource "aws_security_group" "this" {
name = local.security_group_name
description = "Security Group for Elastic File System ${var.name}"
vpc_id = var.vpc_id
tags = merge(
local.tags,
{
Name = var.name
},
)
}
resource "aws_security_group_rule" "ingress" {
security_group_id = aws_security_group.this.id
description = "Allow inbound SFTP traffic from CIDR blocks"
type = "ingress"
cidr_blocks = var.ingress_cidr_blocks
from_port = 2049
to_port = 2049
protocol = "tcp"
}
resource "aws_security_group_rule" "egress" {
security_group_id = aws_security_group.this.id
description = "Allow all outbound traffic to the internet"
type = "egress"
cidr_blocks = ["0.0.0.0/0"]
from_port = 0
to_port = 65535
protocol = "all"
}
resource "aws_efs_mount_target" "this" {
count = length(var.subnets)
file_system_id = aws_efs_file_system.this.id
security_groups = [aws_security_group.this.id]
subnet_id = var.subnets[count.index]
}