Skip to content

Instantly share code, notes, and snippets.

@reganjohnson
Created April 15, 2016 21:55
Show Gist options
  • Save reganjohnson/60f9fd58caa411850b389eac324c3e2d to your computer and use it in GitHub Desktop.
Save reganjohnson/60f9fd58caa411850b389eac324c3e2d to your computer and use it in GitHub Desktop.
Mount EBS using ElasticBeanstalk ebextensions
container_commands:
01_clear_if_mounted:
command: 'if ! mount | grep /media/ebs_volume > /dev/nul; then rm -rf /media/ebs_volume; fi'
02_attach_volume:
command: 'aws ec2 attach-volume --region us-east-1 --volume-id vol-98654c46 --instance-id $(curl -s http://169.254.169.254/latest/meta-data/instance-id) --device /dev/sdh'
test: '[ ! -b /dev/sdh ]'
03_twiddle_fingers:
command: 'sleep 15'
04_make_dir:
command: 'mkdir /media/ebs_volume'
test: '[ ! -d /media/ebs_volume ] && echo "ebs_volume not created"'
05_try_mount:
command: 'mount /dev/sdh /media/ebs_volume'
test: '[ ! mountpoint -q /dev/sdh ] && echo "mountpoint not setup"'
06_format_if_not_already:
command: 'if find /media/ebs_volume/ -maxdepth 0 -empty | read v; then mkfs -t ext3 /dev/sdh; fi'
07_mount:
command: 'mount /dev/sdh /media/ebs_volume'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment