0

I'm really new to AWS ELB and I'm reading about how to automatically mount an EBS volume from a snapshot via the ebextensions script. I've found this post as a reference: https://aws.amazon.com/blogs/devops/customize-ephemeral-and-ebs-volumes-in-elastic-beanstalk-environments/

But basically, my question is, how do I set in the option settings to have it automatically pull the latest snapshot id? Because the snapshots will be updated daily, and I only want to get the latest snapshot without having to edit the ebextensions script each time.

This is what I'm thinking the ebextensions script will be:

commands:
  01mkdir:
    command: "mkdir /mnt/ebs_snapshot"
  02mount:
    command: "mount /dev/sdh /mnt/ebs_snapshot"
option_settings:
  - namespace: aws:autoscaling:launchconfiguration
    option_name: BlockDeviceMappings
    value: /dev/sdh=(how to put latest snapshot id?)

I also found this post: http://www.commandlinefu.com/commands/view/13514/find-the-most-recent-snapshot-for-an-aws-ebs-volume

But not sure how to incorporate that into the ebextensions script file...

0

It's not possible to dynamically specify the block device mappings within the .ebextensions.

Instead, you'll need to create your own script to:

  1. find the latest snapshot,
  2. detach any existing volume from /dev/sdh,
  3. create a new volume from your snapshot, and finally
  4. attach the volume to your instance.

This script you can create/specify within the files and commands seconds of the .ebextensions files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.