Mount AWS EFS to multiple instances
Steps To Follow
Create a VPC and Subnets
Create a Security Group
Create an Amazon Elastic File System(EFS)
Create Two EC2 instances
Attach File System
Test File System
Create a VPC and Subnets
First of all, you have to create a vpc and two subnets in that vpc. you also can use default vpc in your AWS account. you also use following CIDR for new vpc.
Create a Security Group
In the security group section create a security group in your vpc and add three rules in the inbound rule (HTTP, SSH, NFS).
I did not add port 22 but you have to enable it.
Create an Amazon Elastic File System(EFS)
In Amazon console search bar just type efs and click on it. you will see the following interface and click on customize.
Now configure the first step, you can also use the default settings in step 1.
Now click on next and configure the network settings. In the network setting choose vpc in which you want to create a file system and choose mount targets in which you will create your ec2 instances.
Click on next and at step 3 keep it default and go to the next section.
On step 4 review it and click on create. Your file system will look like this.
Create Two EC2 instances & Attach the File system
Click on the launch instance and create two instances of the same steps.
You can use default settings but also customize them.
Make sure in network settings choose your vpc and subnets that you selected during file system creation.
In the storage section click on edit for file system and choose efs file system.
Test File System
Now take SSH of your both ec2 instances, go to the mount point directory and test whether the file system is working or not.
If you face any issues plz watch this file system video below on my YouTube channel
https://youtu.be/hz37v1_AL2A?si=TcxZIKq3WlNBmYCz