forked from utrains/terraform-ec2-efs-s3-job-interview
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathaws-efs.tf
55 lines (54 loc) · 1.74 KB
/
aws-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
# Creating Amazon EFS File system
resource "aws_efs_file_system" "NetSPI_file_system" {
# Creating the AWS EFS lifecycle policy
lifecycle_policy {
transition_to_ia = "AFTER_30_DAYS"
}
# Tagging the EFS File system with its value as NetSPI_file_system
tags = {
Name = "NetSPI_file_system"
}
}
# Creating the EFS access point for AWS EFS File system
resource "aws_efs_access_point" "test" {
file_system_id = aws_efs_file_system.NetSPI_file_system.id
}
# Creating the AWS EFS System policy to transition files into and out of the file system.
resource "aws_efs_file_system_policy" "policy" {
file_system_id = aws_efs_file_system.NetSPI_file_system.id
# The EFS System Policy allows clients to mount, read and perform
# write operations on File system
# The communication of client and EFS is set using aws:secureTransport Option
policy = <<POLICY
{
"Version": "2012-10-17",
"Id": "Policy01",
"Statement": [
{
"Sid": "Statement",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Resource": "${aws_efs_file_system.NetSPI_file_system.arn}",
"Action": [
"elasticfilesystem:ClientMount",
"elasticfilesystem:ClientRootAccess",
"elasticfilesystem:ClientWrite"
],
"Condition": {
"Bool": {
"aws:SecureTransport": "false"
}
}
}
]
}
POLICY
}
# Creating the AWS EFS Mount point in a specified Subnet
# AWS EFS Mount point uses File system ID to launch.
resource "aws_efs_mount_target" "alpha" {
file_system_id = aws_efs_file_system.NetSPI_file_system.id
subnet_id = aws_default_subnet.default_az1.id
}