When running the script we see an error when attaching the new root volume:
11:27:32 Attaching vol-XXXXX as root volume.......................
11:29:45 Failed to attach vol-XXXX
After taking a look at this, we found this is caused by an error in the script. On line
output=ec2-describe-volumes --region $region $image_volume 2>&1
exit_if_failed
state=echo $output | cut -d' ' -f11
It seems that the index (f11) does not consistently produce the attached state of the volume. In some cases we found the state on field 12, while in others we found it at index 13 as shown below.
OUTPUT=ec2-describe-volumes --region eu-west-1 vol-8fc7aa8d 2>&1
echo $OUTPUT |cut -d " " -f 12
/dev/sda1
echo $OUTPUT |cut -d " " -f 11
i-a8debaea
echo $OUTPUT |cut -d " " -f 13
attached
When running the script we see an error when attaching the new root volume:
11:27:32 Attaching vol-XXXXX as root volume.......................
11:29:45 Failed to attach vol-XXXX
After taking a look at this, we found this is caused by an error in the script. On line
output=
ec2-describe-volumes --region $region $image_volume 2>&1exit_if_failed
state=
echo $output | cut -d' ' -f11It seems that the index (f11) does not consistently produce the attached state of the volume. In some cases we found the state on field 12, while in others we found it at index 13 as shown below.
OUTPUT=
ec2-describe-volumes --region eu-west-1 vol-8fc7aa8d 2>&1echo $OUTPUT |cut -d " " -f 12
/dev/sda1
echo $OUTPUT |cut -d " " -f 11
i-a8debaea
echo $OUTPUT |cut -d " " -f 13
attached