-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathefs.tf
45 lines (41 loc) · 1.72 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
///////////////////////////////////////////////////[ ELASTIC FILE SYSTEM ]////////////////////////////////////////////////
# # ---------------------------------------------------------------------------------------------------------------------#
# Create EFS file system
# # ---------------------------------------------------------------------------------------------------------------------#
resource "aws_efs_file_system" "this" {
creation_token = "${local.project}-efs-storage"
tags = merge(
local.default_tags,
{
Name = "${local.project}-efs-storage"
}
)
}
# # ---------------------------------------------------------------------------------------------------------------------#
# Create EFS mount target for each subnet
# # ---------------------------------------------------------------------------------------------------------------------#
resource "aws_efs_mount_target" "this" {
for_each = aws_subnet.this
file_system_id = aws_efs_file_system.this.id
subnet_id = aws_subnet.this[each.key].id
security_groups = [aws_security_group.efs.id]
}
# # ---------------------------------------------------------------------------------------------------------------------#
# Create EFS access point for each path
# # ---------------------------------------------------------------------------------------------------------------------#
resource "aws_efs_access_point" "this" {
for_each = var.efs
file_system_id = aws_efs_file_system.this.id
posix_user {
uid = each.value.uid
gid = each.value.gid
}
root_directory {
path = "/${each.key}"
creation_info {
owner_uid = each.value.uid
owner_gid = each.value.gid
permissions = each.value.permissions
}
}
}