AMIはGUIから作成ボタンを押したり、コマンドラインから作成してもしばらく作成中のため使えません。 AMI作成タスクが複数並んだりするとわりと時間がかかるためコマンドラインで確認できると便利です。
#!/bin/sh
imageId=$1
status_result=`mktemp`
if [ "$imageId" = "" ]; then
echo "usage: $0 {imageId}"
exit 1
fi
aws ec2 describe-images --image-ids $imageId > $status_result
if [ "`cat $status_result | grep available`" = "" ]; then
echo "ami not ready, please wait"
rm -f $status_result
exit 1
fi
rm -f $status_result
echo "$imageId is ready"


