Attaching an EFS file system to an EC2 instance involves three stages: ensuring the security groups allow NFS traffic on port 2049, installing the amazon-efs-utils package on the EC2 instance, and mounting the EFS using either the NFS client or the EFS mount helper. The mount can be made persistent by adding it to /etc/fstab.
Mounting an EFS file system is similar to mounting any NFS share on Linux. AWS provides a helper utility called amazon-efs-utils that simplifies the process and adds features like automatic TLS encryption in transit and mount point recovery. The EFS DNS name automatically resolves to the Mount Target IP in the same Availability Zone as the EC2 instance, ensuring low-latency access.
EFS file system must exist and have a Mount Target in the same AZ as your EC2 instance
EC2 instance Security Group must allow outbound TCP port 2049 to the Mount Target Security Group
Mount Target Security Group must allow inbound TCP port 2049 from the EC2 Security Group
VPC must have DNS Resolution and DNS Hostnames enabled
EC2 instance must be running Linux (EFS does not support Windows)
amazon-efs-utils package must be installed on the EC2 instance for EFS mount helper