Mount AWS EFS to multiple instances

Steps To Follow

  1. Create a VPC and Subnets

  2. Create a Security Group

  3. Create an Amazon Elastic File System(EFS)

  4. Create Two EC2 instances

  5. Attach File System

  6. 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.

Image1

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).

Image2

I did not add port 22 but you have to enable it.

Image3

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.

Image4

Now configure the first step, you can also use the default settings in step 1.

Image5

Image6

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.

Image7

Click on next and at step 3 keep it default and go to the next section.

Image8

On step 4 review it and click on create. Your file system will look like this.

Image9

Create Two EC2 instances & Attach the File system

Click on the launch instance and create two instances of the same steps.

Image10

You can use default settings but also customize them.

Image11

Make sure in network settings choose your vpc and subnets that you selected during file system creation.

Image12

In the storage section click on edit for file system and choose efs file system.

Image14

Image15

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.

Image21

Image22

If you face any issues plz watch this file system video below on my YouTube channel

https://youtu.be/hz37v1_AL2A?si=TcxZIKq3WlNBmYCz