I am trying to create an auto scaling group that will rebuild two reverse proxy ec2 instances which have a shared elastic file system for a near identical httpd config file. The template doesn't seem to allow an efs to be mounted. Can it be done with the user data in the advanced section so it mounts after booting?
Note: you need to ensure that amazon-efs-utils
is installed and that the security group allow connections for nfs.
You could do something like this inside User Data:
#!/bin/bash
sudo mkdir /mnt/efs
sudo mount -t efs ${FILE_SYSTEM_ID} ${EFS_MOUNT_POINT}/
echo "${FILE_SYSTEM_ID}:/ ${EFS_MOUNT_POINT} efs _netdev,noresvport,tls,iam 0 0" | sudo tee -a /etc/fstab
The first two lines mount the EFS filesystem, the third line add an entry in /etc/fstab to auto-mount the filesystem after every reboot.