AWS Builder Center

Understanding Amazon EFS Mount Targets and Troubleshooting Connectivity

How to make and connect Mount Targets to Amazon EFS

When working with Amazon Elastic File System (EFS), creating a file system is only part of the process. Your EC2 instances also need a working network path to access it.
One concept that initially confused me was the purpose of EFS mount targets and why their availability zone placement matters.
In this article, I'll explore how EFS mount targets work, how EC2 instances connect to them, and how to troubleshoot common connectivity problems.

1. What Is an EFS Mount Target?

Amazon EFS is a managed network file system that allows multiple EC2 instances to access shared files simultaneously.
Unlike Amazon EBS, which provides block storage typically attached to an EC2 instance, EFS provides shared file storage over the network.
However, EC2 instances cannot simply access an EFS file system without a network connection.
This is where mount targets come in.
An EFS mount target provides a network endpoint inside a VPC through which clients can access the file system.
Each mount target is associated with:
  • A subnet.
  • A network interface.
  • A private IP address.
  • A security group.

2. Why Do Availability Zones Matter?

Imagine an application running across two Availability Zones:
  • EC2 Instance A runs in Availability Zone A.
  • EC2 Instance B runs in Availability Zone B.
Both instances need access to the same EFS file system.
A common architecture is to create an EFS mount target in each Availability Zone.
This allows instances to connect through a mount target in their own Availability Zone.
The architecture looks like this:
EC2 Instance A → EFS Mount Target A EC2 Instance B → EFS Mount Target B
Both mount targets provide access to the same EFS file system.
This is particularly useful when building highly available applications.

3. Understanding Mount Target States

When creating an EFS mount target, AWS reports its lifecycle state.
Some important states include:
  • Creating: AWS is provisioning the mount target.
  • Available: The mount target is ready to accept connections.
  • Updating: AWS is modifying the mount target.
  • Deleting: The mount target is being removed.
  • Deleted: The mount target has been removed.
  • Error: The mount target encountered a problem.
One important lesson is that creating a mount target does not mean it is immediately ready.
Applications should wait until the mount target becomes available before attempting to mount the file system.

4. Common EFS Connectivity Problems

Suppose an EC2 instance cannot mount an EFS file system.
Instead of immediately recreating the file system, I would investigate the following.
Security groups
EFS uses the NFS protocol, which operates over TCP port 2049.
The EFS mount target security group must allow inbound TCP traffic on port 2049 from the EC2 instance's security group or another appropriately scoped source.
The EC2 security group must also allow the corresponding outbound traffic.
Availability Zone placement
Check whether a mount target exists in the Availability Zone where the EC2 instance is running.
This helps ensure that the intended mount target is available locally.
Mount target state
Check whether the mount target is actually in the Available state.
An endpoint that is still being created cannot be treated as ready.
Network configuration
Verify that the EC2 instance and EFS mount target are in compatible network configurations and that network ACLs do not block the required traffic.

5. Useful AWS CLI Commands

You can inspect an EFS file system's mount targets using:
```bash aws efs describe-mount-targets \ --file-system-id fs-xxxxxxxx ```
To inspect the security groups associated with a mount target:
```bash aws efs describe-mount-target-security-groups \ --mount-target-id fsmt-xxxxxxxx ```
These commands help identify whether the mount target exists, which subnet it belongs to, and whether it has reached the expected state.

6. Key Takeaways

Amazon EFS is useful when multiple compute resources need shared file storage.
However, understanding its networking requirements is just as important as understanding its storage capabilities.
The main things to remember are:
  • Mount targets provide network access to EFS.
  • Mount targets belong to individual subnets.
  • Availability Zone placement matters for local connectivity.
  • NFS uses TCP port 2049.
  • A mount target should be Available before clients attempt to mount it.
Understanding these details makes it easier to troubleshoot EFS rather than repeatedly changing configurations without knowing the cause of a problem.
Have you encountered any EFS mounting issues when working with EC2? I'd be interested to hear what caused them.

Please like this article and go to my profile and like the content there. If you reply, I will go to your content listed on your profile and like it.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article