Mount AWS EFS to multiple instances
Tags: aws, devops, cloudcomputing, awscommunity
Published: 2024-03-02 07:28:57

**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 the following CIDR for new vpc.

![Image1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vwhoku3hpnxcb8x48no9.PNG)

## Create a Security Group
In security group section create a security group in your vpc and add three rules in inbound rule (HTTP, SSH, NFS).

![Image2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kfr04fm7icj7esk3jc7r.PNG)
I did not add port 22 but you have to enable it.

![Image3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vm7xk8n6q3nwnrb5umom.PNG)

## Create an Amazon Elastic File System(EFS)
In amazon console search bar just type efs and click on it.
you will see following interface and click on customize.

![Image4](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v9tynbb55581k6lvyo25.PNG)
Now configure first step, you can also use default settings in step-1.

![Image5](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0lcenayc7xlauln624x4.PNG)
![Image6](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jttqvm080kanp9lm0e6u.PNG)
Now click on next and configure the network settings.
In network setting choose vpc in which you want to create file system and choose mount targets in which you will create your ec2 instances.

![Image7](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j05lxxm81aad9zsvf5wz.PNG)
Click on next and at step 3 keep it default and go to next section.

![Image8](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lpubjzcs0hcjzwjo3f86.PNG)
On step 4 review it and click on create.
Your file system will look like this.

![Image9](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dgdl8x7oqg2rfdqgaf1r.PNG)

## Create Two EC2 instances & Attach File system
Click on launch instance and create two instances of same steps.

![Image10](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m97kwbl3mg8l1nj3mhg4.PNG)
You can use default settings but also can customize it.

![Image11](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nt0o5c32ulbemozbged9.PNG)
Make sure in network settings choose your vpc and subnets that you selected during file system creation.
![Image12](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g186ralhjkv5pzfujb7h.PNG)
In storage section click on edit for file system and choose efs file system.

![Image14](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6sd1svks7grcdqtxq9u3.PNG)

![Image15](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j3qhpyucq0gdv3qko0xo.PNG)

## Test File System
Now take SSH of your both ec2 instances, go to mount point directory and test either file system is working or not.

![Image21](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cx3cd1404op7mj2gtch4.PNG)

![Image22](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/09he3udw340h8e25lu2y.PNG)
**If you face any issue plz watch this file system video below on my youtube channel**

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