I created an EC2 amazon instance (ubuntu) and created a volume from an available snapshot. The volume has been successfully attached to my instance as /dev/sdf
.
In my CloudFormation UserData section I had the attach-volume
command and mount
command execute sequentially without a delay. I introduced a 5 second delay between the attach-volume command and mount command and it solved the problem.
aws ec2 attach-volume --volume-id $volumeId --instance-id $instanceId --device /dev/xvdf
sleep 5
mount /dev/xvdf /db -t ext4