I am trying to use elastic file system (EFS) in AWS... My goal is to auto-mount it using /etc/fstab
Since EC2 instances are auto scaled across available zones, EFS mount IP's change depending on the instance's zone. At the moment AWS provides this command to mount it to the correct zone...
sudo mount -t nfs4 -o nfsvers=4.1 $(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone).fs-xxxx.efs.us-east-1.amazonaws.com:/ efs
However, there is some issues with EFS DNS url's, I was only able to connect via provided EFS IP's. So I created a bash script to obtain the correct IP pertaining to zone...
nano /efsmount.sh
#!/bin/sh
CURR_ZONE=$(/usr/bin/curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)
if [ "$CURR_ZONE" == "us-east-1e" ];then
echo "172.xx.xx.xx"
fi
... more if statements to cover all zones
I can mount using this script
sudo mount -t nfs4 -o nfsvers=4.1 $(/efsmount.sh):/ /efs
Now my question is... how do I auto mount using fstab?
Something like this does not work
$(/efsmount.sh):/ /efs nfs auto,noatime,nolock,bg,nfsvers=4.1,intr,tcp,actimeo=1800 0 0
Thanks