Connecting to EFS from EC2 Instance Using Session Manager

Connecting to EFS from EC2 Instance Using Session Manager

Overview :-

Hey there, fellow AWS enthusiasts! Today, we’re going to chat about something pretty cool — connecting your EC2 instance to an EFS (Elastic File System) using Session Manager. It’s like introducing two friends who are going to get along great!

Now, why would you want to connect these? Well, imagine your EC2 instance needs access to a whole bunch of files, but you don’t want to store them directly on the instance. That’s where EFS comes in handy! It’s like having a massive external hard drive that your EC2 can tap into whenever it needs.

Prerequisites :-

Before we dive in, let’s make sure we have everything we need:

  1. An AWS Account: I’m assuming you’ve already got this one covered. If not, it’s super easy to set up!

  2. An EC2 Instance: Make sure it’s up and running in your desired region.

  3. An EFS File System: This should be created in the same region as your EC2 instance. It’s like making sure your friends live in the same neighborhood!

  4. IAM Role for EC2: Your EC2 instance needs the right permissions to talk to EFS. It’s like giving your friend the secret handshake to enter the clubhouse.

  5. VPC and Security Groups: Your EC2 and EFS need to be in the same VPC, and your security groups should allow the necessary traffic. Think of this as making sure your friends are invited to the same party.

  6. AWS CLI: This should be installed and configured on your local machine. It’s your remote control for all things AWS.

  7. Session Manager Plugin: Make sure this is installed on your local machine. It’s the magic wand that lets you connect to your EC2 instance without SSH.

Step 1: Log in to AWS Management Console

  1. Log in to your AWS Management Console and Navigate to EC2 Dashboard

  2. In the AWS Management Console, go to the EC2 Dashboard.

  3. On the EC2 Dashboard, in the navigation pane, choose “Instances (running).”

  4. Choose one of the instances from the list, and in the details pane, click the “Connect” button.

  5. After clicking “Connect,” choose the “Session Manager” option from the available connection options, and click “Connect.”

  6. A terminal session to your EC2 instance will be opened directly in the AWS Management Console.

  7. In the terminal session, create a directory on your EC2 instance using the command: sudo mkdir efs/

Step 2: Navigate to EFS Service

  1. Open the Amazon EFS service in the AWS Management Console.

  2. Select the EFS file system you want to connect to the EC2 instance. Once opened, click on “Attach.”

  3. From the file system connection options, copy the NFS Client command.

  4. Paste the copied command in the Session Manager terminal session. Check whether the files or folders are accessible from the EC2 instance using SSM.

Step 3: Interact with EFS

  1. You can now interact with the EFS file system directly from the EC2 instance terminal session.

Conclusion :-

And there you have it, folks! We’ve walked through the basics of connecting your EC2 instance to EFS using Session Manager. It’s a powerful combo that can really boost your cloud storage game. Whatever you end up doing, I hope this guide has helped you understand the basics. Happy cloud computing, and don’t forget to have fun while you’re at it!