Created
July 19, 2017 09:56
-
-
Save mattfield/c7fa990972989be93e31dac510c68ff7 to your computer and use it in GitHub Desktop.
Bash snippet to poll attachment of EC2 volume
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EC2_INSTANCE_ID=$(curl -s http://instance-data/latest/meta-data/instance-id) | |
DEVICE=/dev/sda | |
DATA_STATE="unknown" | |
until [ "$DATA_STATE" == "attached" ]; do | |
DATA_STATE=$(aws ec2 describe-volumes \ | |
--region $REGION \ | |
--filters \ | |
Name=attachment.instance-id,Values=$EC2_INSTANCE_ID \ | |
Name=attachment.device,Values=$DEVICE \ | |
--query Volumes[].Attachments[].State \ | |
--output text) | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment