Skip to content

Instantly share code, notes, and snippets.

@BenHigginbottom
Last active July 9, 2019 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenHigginbottom/2eb3c55d88d3845b2cb2b1cb978f9091 to your computer and use it in GitHub Desktop.
Save BenHigginbottom/2eb3c55d88d3845b2cb2b1cb978f9091 to your computer and use it in GitHub Desktop.
EFS Userdata Mount
#!/bin/bash
EC2_AVAIL_ZONE=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)
mount_target_DNS_a=``
mount_target_DNS_b=``
mount_target_DNS_c=``
efs_mount_point=``
case "$EC2_AVAIL_ZONE" in
eu-west-2a) echo "mounting eu-west-2a mount point"
mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport "$mount_target_DNS_a":/ ~/"$efs_mount_point"
;;
eu-west-2b) echo "mounting eu-west-2b mount point"
mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport "$mount_target_DNS_b":/ ~/"$efs_mount_point"
;;
eu-west-2c) echo "mounting eu-west-2c mount point"
mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport "$mount_target_DNS_c":/ ~/"$efs_mount_point"
;;
*) echo "PANIC - Cannot determine AZ"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment