forked from austincloudguru/terraform-aws-efs
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.tf
56 lines (51 loc) · 1.16 KB
/
main.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
#------------------------------------------------------------------------------
# Create EFS
#------------------------------------------------------------------------------
resource "aws_security_group" "this" {
name = var.efs_name
description = "Allows for NFS traffic for ${var.efs_name}"
vpc_id = var.vpc_id
ingress {
from_port = 2049
protocol = "tcp"
to_port = 2049
self = true
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [
"0.0.0.0/0"]
}
tags = merge(
{
"Name" = var.efs_name
},
var.tags
)
}
resource "aws_efs_file_system" "this" {
creation_token = var.efs_name
encrypted = var.encrypted
lifecycle {
ignore_changes = [
size_in_bytes[0].value,
size_in_bytes[0].value_in_standard
]
}
tags = merge(
{
"Name" = var.efs_name
},
var.tags
)
}
resource "aws_efs_mount_target" "this" {
count = length(var.subnet_ids) > 0 ? length(var.subnet_ids) : 0
file_system_id = aws_efs_file_system.this.id
subnet_id = var.subnet_ids[count.index]
security_groups = [
aws_security_group.this.id
]
}