A Simple Step-by-Step Guide for Deploying EC2 Instances with Shared EFS Storage
Topic: Mounting NFS (Network file system) on EC2 Instance
Deploying EC2 Instances with Shared EFS Storage
Your company, Cloud Native Solutions, is expanding its cloud infrastructure to support a distributed application. The application runs on two Amazon EC2 instances that need to share files in real-time. To achieve this, you must configure Amazon Elastic File System (EFS) to allow both instances to read and write to the same file system.
This project will test your ability to configure AWS storage solutions, manage security groups, and ensure high availability in a cloud environment
This guide will walk you through setting up two Amazon EC2 instances that share a common Amazon Elastic File System (EFS) for real-time file sharing.
Prerequisites
AWS account with necessary permissions
Basic knowledge of AWS EC2, EFS, and Security Groups
AWS CLI or AWS Management Console access
Reminder….READ the steps first then Images below….
Step 1: Create an Amazon Elastic File System (EFS)
Navigate to the EFS Console
Open the AWS Management Console.
Go to Amazon Elastic File System (EFS).
Click Create file system.
Give your file a name
Click on customize
- Configure the File System Using the following steps
Step 1 File system settings: Give your file a name move on with the default settings and click Next
Step 2 Network Access: Move on with the default mode and click Next
Step 3 File system Policy: Select Enforce in-transit encryption for all clients
Step 4 Click Next and then Create.
Step 2: Deploy Two EC2 Instances Using the following steps.
Launch EC2 Instances
Navigate to the EC2 Dashboard or search for Ec2 at the search bar and click on it.
Click Launch Instance.
Give your instance(server) a name of your choice (e.g Esf-server1 for the 1st Ec2 instance & Efs-server2 for the 2nd Ec2 instance.
Choose an Amazon Linux image
Select an appropriate instance type (t3.micro).
On the key pair drop-down Select proceed without a key pair.
Change the security group name to your desired recognized name(e.g., Efs 1 for the 1st Ec2 & Efs 2 for the 2nd Ec2 instance).
Ensure both instances are in the same VPC as the EFS.
Launch Instance.
Remember to follow the same process and create the two(2) Ec2 instances.
Step 3: Go to security groups below Network & security and Edit the Security Inbound Rules for both the Two EC2 Instances Using the following steps.
Click on the eclipses on the top left of your screen.
Navigate to the security group and click on it.
Click the Default security group ID.
Navigate to Edit inbound rules & click on it.
Click on Add rule.
Click the drop-down for custom Tcp search for NSF and click on it.
Click the search bar right to the custom box and scroll down to find the security group you created for your Ec2 instance.(e.g search the security group for the 1st Ec2 instance while adding a rule for the 1st instance and same for the 2nd Ec2 instance)
Click on Save rule
Note that this step applies to all Ec2 instances
After successfully adding the inbound security group rule to your Ec2 instances
The next step is to connect your instances to mount your instances to the EFS ….Use the steps to both Ec2 instances on how to connect and mount your instances using the cloud shell terminal.
Navigate and click on instances on the left side of your screen.
Check the box of the instance you wish to connect.
Click on Connect at the top of your screen, it will take you to the next page …leave everything in default mode and click on Connect.
You will be redirected to the cloud shell terminal where you will run some commands to connect and mount your EFS….but before that.
Minimize and navigate back to your console search for EFS and click on it
Click on your file name and open
Click on Attach
Copy the first sudo mount link below Using the Efs mount helper and save it somewhere.
Navigate back to your Cloud shell Terminal run the following commands shown in the image below and mount your Ec2 instances to Efs….
NOTE that you have to follow the same steps for both your Ec2 instances
Remember that the 3rd command sudo mount -t efs -o tls fs……… on the image below is the Efs command which you copy when you click on Attach.
Join me on this cloud adventure and elevate your tech skills! Sign in to the Azure portal, follow my easy instructions, and unleash the power of Being in the cloud.
Subscribe to my blog for more tech tips and tricks that will keep you ahead in the digital game. Your journey to mastering Cloud computing starts here!
🌟 Thank you for being a part of this incredible journey! Together, let's unlock new opportunities and make the most out of our digital experiences. Happy computing! 🌟