Skip to content

Commit

Permalink
Making sure volume is deatached and available before mounting
Browse files Browse the repository at this point in the history
  • Loading branch information
adenot committed Jun 16, 2021
1 parent dca17e7 commit fda0094
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions userdata-ebs.tpl
Expand Up @@ -13,8 +13,10 @@ INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id |
AZ="`wget -q -O - http://169.254.169.254/latest/meta-data/placement/availability-zone || die \"wget availability-zone has failed: $?\"`"
AWS_REGION="`echo \"$AZ\" | sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:'`"

aws ec2 detach-volume --region $${AWS_REGION} --volume-id $${EBS_ID} --force
sleep 30
sleep 60
aws ec2 wait --region $${AWS_REGION} volume-available --volume-ids $${EBS_ID}
aws ec2 detach-volume --region $${AWS_REGION} --volume-id $${EBS_ID} --force || true
sleep 60
aws ec2 attach-volume --region $${AWS_REGION} --volume-id $${EBS_ID} --instance-id $${INSTANCE_ID} --device /dev/sdf
aws ec2 wait --region $${AWS_REGION} volume-in-use --volume-ids $${EBS_ID}

Expand Down

0 comments on commit fda0094

Please sign in to comment.