AWS Amazon EFS Mount Target
This page shows how to write Terraform and CloudFormation for Amazon EFS Mount Target and write them securely.
aws_efs_mount_target (Terraform)
The Mount Target in Amazon EFS can be configured in Terraform with the resource name aws_efs_mount_target
. The following sections describe 1 example of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_efs_mount_target" "mount_us_east_1a" {
file_system_id = aws_efs_file_system.fs.id
subnet_id = data.aws_subnet.us_east_1a.id
security_groups = [aws_security_group.efs_sg.id]
}
Parameters
-
availability_zone_id
optional computed - string -
availability_zone_name
optional computed - string -
dns_name
optional computed - string -
file_system_arn
optional computed - string -
file_system_id
required - string -
id
optional computed - string -
ip_address
optional computed - string -
mount_target_dns_name
optional computed - string -
network_interface_id
optional computed - string -
owner_id
optional computed - string -
security_groups
optional computed - set of string -
subnet_id
required - string
Explanation in Terraform Registry
Provides an Elastic File System (EFS) mount target.
Tips: Best Practices for The Other AWS Amazon EFS Resources
In addition to the aws_efs_file_system, AWS Amazon EFS has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
aws_efs_file_system
Enable at rest encryption of EFS
It is better to enable at rest encryption of EFS to reduce the risk of data leakage.
AWS::EFS::MountTarget (CloudFormation)
The MountTarget in EFS can be configured in CloudFormation with the resource name AWS::EFS::MountTarget
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: AWS::EFS::MountTarget
Condition: Has1Subnets
Properties:
FileSystemId: !Ref ElasticFileSystem
SubnetId: !Select [ 0, !Ref SubnetList ]
SecurityGroups: [ !Ref MountTargetSecurityGroup ]
Type: AWS::EFS::MountTarget
Condition: Has1Subnets
Properties:
FileSystemId: !Ref ElasticFileSystem
SubnetId: !Select [ 0, !Ref SubnetList ]
SecurityGroups: [ !Ref MountTargetSecurityGroup ]
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref ElasticFileSystemRetain
SecurityGroups:
- !Ref SecurityGroup
SubnetId: !Select [ 0, !Ref Subnet ]
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref ElasticFileSystemRetain
SecurityGroups:
- !Ref SecurityGroup
SubnetId: !Select [ 0, !Ref Subnet ]
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref EFSJenkinsHomeVolume
SecurityGroups:
- !Ref SecurityGroupEFS
SubnetId: !Ref SubnetPublicA
"Type": "AWS::EFS::MountTarget"
},
"SonarqubeEFSMount2": {
"Properties": {
"FileSystemId": {
"Ref": "SonarqubeEFS"
"Type" : "AWS::EFS::MountTarget",
"Properties" : {
"FileSystemId": { "Ref": "ArtifactoryEFS" },
"SecurityGroups": { "Ref": "EfsSg" },
"SubnetId": { "Fn::Select": [ "0", { "Ref": "EfsSubnet" } ] }
}
"Type" : "AWS::EFS::MountTarget",
"Properties" : {
"FileSystemId": { "Ref": "ArtifactoryEFS" },
"SecurityGroups": { "Ref": "EfsSg" },
"SubnetId": { "Fn::Select": [ "0", { "Ref": "EfsSubnet" } ] }
}
"Type": "AWS::EFS::MountTarget",
"Properties": {
"SubnetId": {
"Ref": "PrivateSubnet0"
},
"FileSystemId": {
"Type" : "AWS::EFS::MountTarget",
"Properties" : {
"FileSystemId" : { "Ref": "FileSystem" },
"SecurityGroups" : [{ "Ref": "EFSSecurityGroup" }],
"SubnetId" : {
"Fn::ImportValue": {
Parameters
-
IpAddress
optional - String -
FileSystemId
required - String -
SecurityGroups
required - List -
SubnetId
required - String
Explanation in CloudFormation Registry
The
AWS::EFS::MountTarget
resource is an Amazon EFS resource that creates a mount target for an EFS file system. You can then mount the file system on Amazon EC2 instances or other resources by using the mount target.
Frequently asked questions
What is AWS Amazon EFS Mount Target?
AWS Amazon EFS Mount Target is a resource for Amazon EFS of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS Amazon EFS Mount Target?
For Terraform, the a-sinkavets/devops-task-02 source code example is useful. See the Terraform Example section for further details.
For CloudFormation, the mozilla/MozDef, gustcol/Canivete and pavantocemca40/DevOps source code examples are useful. See the CloudFormation Example section for further details.