Introduction
Amazon Elastic File System (EFS) is a fully managed, scalable, and shared file storage solution provided by AWS. It allows multiple EC2 instances to access the same file system simultaneously, making it ideal for shared workloads or distributed applications.
In this guide, I will walk through the steps to implement EFS with two Amazon Linux EC2 instances, highlighting its setup and benefits.
Implementation
- Create Security Groups
- First, I’ll create two EC2 security groups, each configured to allow SSH access for their respective EC2 instances.
- Next, I’ll create another security group with NFS access allowed for the previously created security groups.
- Now, we have all the required security groups.
- Create an NFS File System
- Navigate to EFS, and I’ll create an NFS file system.
- Enter the name, select the VPC, and click “Customize.”
- I’ll uncheck automatic backups, encryption at rest, and lifecycle management since this is a demo. Then, we’ll select Bursting.
- Next, we’ll create mount targets by selecting the NFS security group we created earlier for each availability zone (AZ).
- Finally, review the settings and create the NFS file system.
- Create EC2 Instances
- Next, we’ll create two EC2 instances with a Linux operating system. In this demo, I’ll launch
instance_1
inap-southeast-1a
andinstance_2
inap-southeast-1b
. During the creation process, make sure to select the correct VPC, subnets, and the existing security group we created earlier.
- Next, we’ll create two EC2 instances with a Linux operating system. In this demo, I’ll launch
- In the “Configure storage” section, click “Edit” under File systems.
- Select the EFS we created earlier and uncheck “Automatically create and attach security groups.”
- Now, we have our EC2 instances set up.
Testing
- I created
sample.txt
under/mnt/efs/fs1/
oninstance_1
. We can also access that file oninstance_2
.
Conclusion
By following these steps, you’ve successfully implemented Amazon EFS with two Amazon Linux EC2 instances. This setup allows you to share data seamlessly between instances and scale your applications without worrying about storage limitations.
Happy cloud computing!
Hello.
There is reasonable evidence that parts of this article have been machine-generated.
We would appreciate it if you could avoid publishing AI-generated content (full or partial texts, art, etc.).
Thank you.
Guide: AI-Generated Content = Not Original Content
Hive Guide: Hive 101
If you believe this comment is in error, please contact us in #appeals in Discord