Successfully implemented file sharing between two EC2 instances using Amazon EFS

Successfully implemented file sharing between two EC2 instances using Amazon EFS

Recently, I explored how to set up Amazon EFS (Elastic File System) between two EC2 instances located in different availability zones (us-east-1a and us-east-1b). Here’s how I made it happen:

Steps I Followed

1️⃣ Created an EFS and Two EC2 Instances

  • One in us-east-1a and the other in us-east-1b.

Article content
Article content

2️⃣ Configured Security Groups

  • Allowed NFS inbound rules in both EC2 instances’ security groups.
  • Added the EFS security group (sg-0eba57961e20687aa) to both instances.

Article content
efs-server1
Article content
efs-server2

  • Updated the EFS security group to include the EC2 instance security groups (sg-012aa38c2ba75dc74 and sg-03e166a0b74fa9874).

Article content

3️⃣ Installed EFS UtilitiesExecuted the following command on both servers:

yum install -y amazon-efs-utils        
Article content

4️⃣ Mounted EFS on Both Servers

On server1:

Article content

On server2:

Article content
Article content

5️⃣ Tested File Sharing

  • Created two files (file01 and file02) in server1:

cd /efs-server1/
touch file01 file02
ls        
Article content

Verified file sharing by adding content to file01 from server2:

cd /efs-server2/
cat > file01  
Hello, this is from efs-server2!        


Article content

Checked that the changes reflected in server1:

cat file01
Hello, this is from efs-server2!        
Article content

Advantages of Using EFS Across EC2 Instances

1️⃣ Scalability: Automatically grows and shrinks as you add or remove data.

2️⃣ Shared Access: Enables multiple EC2 instances to access the same file system.

3️⃣ High Availability: Works seamlessly across multiple availability zones.

4️⃣ Simple Management: No need for manual provisioning or managing storage.

5️⃣ Cost-Effective: Pay for what you use without upfront costs.

AMBRESH R

Aspiring AWS and DevOps Engineer| CI/CD | Cloud Infrastructure | Automation Enthusiast

5mo

Very informative

To view or add a comment, sign in

More articles by Sanjay H B

Insights from the community

Others also viewed

Explore topics