Amazon Elastic File System (Amazon EFS) is a fully managed, serverless, and scalable file storage service that allows you to share file data across multiple Amazon EC2 instances and other AWS services. It’s ideal for workloads that require high throughput and concurrent access to file data. It's built for workloads that require shared access to a file system with high throughput and low latency.
Amazon Elastic File System (EFS) Setup Guide
Step 1: Create an EFS File System
- Navigate to the Amazon EFS service.
- Click on the Create file system button.
- Configure File System Settings:
Name: Optionally, provide a name for the file system to easily identify it.
VPC: Select the Virtual Private Cloud (VPC) where you want to create the EFS. The VPC should match the network where your EC2 instances are running.
Availability and Durability: You can opt for the default settings, which provide high availability across multiple availability zones.
- Choose a Performance Mode:
General Purpose: Suitable for latency-sensitive use cases like web serving and content management.
Max I/O: Use this mode for workloads requiring higher throughput and can tolerate slightly higher latencies.
- Select a Throughput Mode:
Bursting Throughput: This is the default mode and works well for most applications. It automatically adjusts throughput based on file system activity.
Provisioned Throughput: Select this if you need a consistent level of throughput regardless of file size or I/O operations.
- Configure Network Access:
Mount Targets: EFS requires mount targets in each availability zone (AZ) where you want to access the file system. Ensure that mount targets are created in the subnets where your EC2 instances are deployed.
Security Groups: Associate the security groups that allow inbound NFS traffic from your EC2 instances.
- Review the settings you've configured, and then click Create.
Step 2: Create a Security Group
- In the left-hand menu, under Network & Security, click Security Groups.
- Create a New Security Group.
- Configure the Security Group:
Name: Provide a name (e.g., efs-nfs-ssh-sg).
Description: Describe the purpose (e.g., NFS access for EFS).
VPC: Select the appropriate VPC where EC2 instances and EFS are located.
Step 3: Add Inbound Rules for NFS and SSH
- Add an SSH Rule:
Type:
SSH
.
Port:22
.
Source: Choose My IP or Anywhere (0.0.0.0/0
).
- Add an NFS Rule:
Type:
Custom NFS
.
Port:2049
.
Source: Choose My IP or Anywhere (0.0.0.0/0
). For better security, it's recommended to restrict the source to the specific subnet(s) or security group(s) that need access.
Step 4: Mount the EFS on EC2 Instances
- Ensure EC2 instances are in the same VPC and subnets as the EFS mount targets.
- Install NFS Utilities on EC2:
- Connect to your EC2 instance.
- Install NFS utilities using the appropriate package manager for your OS.
sudo su
yum install amazon-nfs-utils
- Then attach your EFS to both of your EC2 instances using the NFS client.
Step 5: Create and Access Files Across Instances
- Create a File on Instance 1. Navigate to the EFS mount directory:
cd efs
- Create a file:
echo "Hello World" > helloworld.txt
- Access the File on Instance 2. Navigate to the same EFS mount directory:
cd efs
- Verify the file:
ls -l
cat helloworld.txt
- The contents should match what was written on Instance 1.
Conclusion
Amazon EFS offers scalable, reliable, and fully managed shared file storage for EC2 and other AWS services. Its ease of use, high availability, and flexible performance options make it ideal for a variety of workloads, from web hosting to data analytics. With built-in security and seamless AWS integration, EFS is a powerful solution for simplifying cloud file storage management.
Top comments (0)