# Mount S3 bucket on /s3/home for all new users.
amazon-linux-extras install -y epel
yum install -y s3fs-fuse curl
declare s3home="/s3/home" bucket="mybucket" iamrole=""
iamrole="$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/)"
mkdir -pv "$s3home"
sed -i "s,HOME=/home,HOME=$s3home," /etc/default/useradd
echo "s3fs#$bucket $s3home fuse _netdev,nonempty,users,rw,sync,noatime,allow_other,umask=0000,iam_role=$iamrole 0 0" | tee -a /etc/fstab
mount "$s3home"