Tara Prasad Gurung
Tara Prasad Gurung

Reputation: 3569

How to mount the AWS EFS with EC2 on different availability zone?

I am trying to mount the EFS with EC2 and what I have done is created the EFS on private subnet and EC2 on public subnet. The private and public subnets are in different availability regions for example us-east-1 and us-east-2.

I am able to connect the EC2 and EFS if putting both of them in public network.As per the official AWS docs its says

"Ensure that there's an Amazon EFS mount target in the same Availability Zone as the Amazon EC2 instance"

I don't want to put the EFS in public subnet.

When mounting the EFS to the EC2 I am getting this error message:

sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport fs-b3XXXXXXXXXXXXXXXXX.amazonaws.com:/ /mnt/wordpress

mount.nfs4: Failed to resolve server fs-b3XXXXXXXXXXXXXXXXX.amazonaws.com: No address associated with hostname

The dhcp and dns related settings for VPC are all turned on.

Upvotes: 1

Views: 4120

Answers (1)

Michael - sqlbot
Michael - sqlbot

Reputation: 179154

I don't want to put the EFS in public subnet.

That's good. You shouldn't, although it technically would not matter because EFS endpoints are still private even when placed in a public subnet.

But if you only have two subnets -- one public, one private -- in a VPC, then they almost certainly should be in the same availability zone. Traffic crossing AZ boundaries is billable per gigabyte, and this is exactly why you should never try to mount EFS across zone boundaries. This error appears to be protecting you from yourself.

As noted, you probably shouldn't have one subnet one AZ and one in another, without a compelling reason, so fixing that is one solution. Another solution is to simply add a new private subnet in the correct zone. EFS has no problem crossing subnet boundaries within a zone, and there is no bandwidth charge in that case.

Upvotes: 3

Related Questions