Amazon Elastic File System (EFS) Hands-On Guide
In this hands-on session, we explored Amazon Elastic File System (EFS) and how to create, configure, and mount it to EC2 instances. Below is a structured guide summarizing all the steps.
1. Creating an EFS File System
- Navigate to the EFS Console
- Click on Create file system.
- (Optional) Provide a name or leave it blank.
- Choose a VPC (default is fine).
- Customize File System Settings
- File System Type:
- Regional (Recommended for production) – Spans multiple Availability Zones (AZs) for high durability.
- One Zone (Cost-effective) – Restricted to a single AZ (not recommended for production).
- Automatic Backups: Keep enabled for data protection.
- Lifecycle Management: Saves costs by transitioning data across storage tiers:
- 30 days inactive → Moves to Infrequent Access.
- 90 days inactive → Moves to Archive.
- Accessed again → Moves back to Standard.
- Encryption: Keep enabled (best practice).
- Performance Settings:
- Bursting Throughput Mode – Scales based on storage size.
- Elastic Throughput Mode (Recommended) – Provides dynamic throughput without pre-configured limits.
- Provisioned Throughput Mode – Best when throughput needs are known in advance.
- Performance Mode:
- General Purpose (Recommended) – Low latency, good for most applications.
- Max I/O – Suitable for high-throughput workloads but with increased latency.
- Network Access Configuration
- Choose a VPC (default VPC is fine).
- EFS will automatically create mount targets for each AZ.
- Assign a security group (create a new one for EFS if needed).
- Review and Create
- Ensure settings are correct, then Create the EFS file system.
2. Attaching EFS to EC2 Instances
Step 1: Launch EC2 Instance A
- Navigate to the EC2 Console and click Launch Instance.
- Configure the instance:
- Name: Instance A.
- AMI: Amazon Linux 2.
- Instance Type:
t2.micro (Free-tier eligible).
- Key Pair: No key pair (use EC2 Instance Connect for SSH).
- Network Settings: Default VPC, select subnet in
eu-west-1a.
- Security Group: Create a new one or use an existing EFS security group.
- Attach EFS Storage:
- Under "Advanced details" → Add an EFS file system.
- Mount path:
/mnt/efs/fs1/.
- AWS automatically mounts the EFS using user data scripts.
- Launch the instance.
Step 2: Launch EC2 Instance B
- Repeat the above steps, but:
- Name it Instance B.
- Place it in eu-west-1b.
- Select the same EFS file system.
3. Testing EFS File Sharing
-
Connect to Instance A:
ls /mnt/efs/fs1/
sudo su
echo "hello world" > /mnt/efs/fs1/hello.txt
cat /mnt/efs/fs1/hello.txt
- Creates
hello.txt in EFS.