How to connect to EFS via CloudShell

A tricky topic when trying to connect to EFS is that you need to create an EC2 instance. There is not an easy way to mount as a network drive in your local laptop. But what if your organization is somehow bureaucratic and you need a thousand approvals just to run your new EC2 locally for the first time?

A quick win is to use CloudShell and an EC2 instance directly from the AWS Console. Just follow these steps:

  1. Create an EC2 instance with any Linux.
  2. Create a Key.
  3. Launch it.
  4. Create a Bucket in S3.
  5. Upload the Key.
  6. Open AWS CloudShell.
  7. Download the Key: aws s3 cp s3://MY_BUCKET/MY_KEY.pem .
  8. Give the right permissions to the Key: chmod 400 "MY_KEY.pem"
  9. Get your configuration from the Connect section in your EC2 instance.
  10. Connect to your EC2 instance via SSH: ssh -i "MY_KEY.pem" ec2-user@ec2MY_CONFIGURATOIN.MY_REGION.compute.amazonaws.com
  11. Install the Amazon EFS Client: sudo yum install -y amazon-efs-utils
  12. Create a folder called efs  sudo mkdir efs .
  13. Mount your EFS via its IP (you can get from the Attach button): sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport MY_IP:/ efs
And that's all, now, you can mount your EFS without needing any special permissions in your local laptop.

Notes:
  • If you're wondering why you can't directly connect EFS to your CloudShell, it's because they're in different VPCs. If you try to create a CloudShell with your own VPC connected, it also fails, in my experience. Perhaps this will be fixed in the future.
  • If your EC2 is only available via private IPs, you will need to create a CloudShell using your private VPC.

Comments