Skip to content

Instantly share code, notes, and snippets.

@brianlechthaler
Last active November 25, 2020 23:49
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 brianlechthaler/dc45d166ec50e9bd917869b213363a24 to your computer and use it in GitHub Desktop.
Save brianlechthaler/dc45d166ec50e9bd917869b213363a24 to your computer and use it in GitHub Desktop.
Tool to automatically provision any AWS EFS attached to an EC2 instance running this script
#!/bin/sh
#Store the name of the user who invoked this script to set appropriate permissions later
export invokingUser=$(whoami)
echo "Usage: ./efs-bootstrap.sh <EFS_Filesystem_ID> <MountPoint>"
echo "Example: ./efs-bootstrap.sh fs-deadbeef /mnt/efs/fs1/"
#Ensure target directory exists
sudo mkdir -p $2
#Attempt to mount EFS Filesystem, authenticating with IAM over TLS.
sudo mount -t efs $1:/ $2 -o tls,iam
#Attempt to set proper permissions on EFS directory
sudo chown -R $invokingUser:$invokingUser $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment