awscliでインスタンスの作成をおこなう

レガシーなやつだとこっちに書いたやつですが、 https://hacknote.jp/archives/3165/

python版の方が挙動が軽いので可能なら以下の方法に切り替えると良いと思います。
amiは2014.09.1のAmazonLinuxです。

#/bin/sh

instanceName=$1

SUBNET="subnet-xxxxxxx"
KEYPAIR="xxxxxx"
GROUP="sg-xxxxxx"

AMI="ami-4985b048"
STORAGE='[{"DeviceName": "/dev/xvda", "Ebs":{"SnapshotId": "snap-025e7c85", "VolumeSize": 30, "VolumeType": "standard"}}]'
TYPE="t2.micro"

result_id=`aws ec2 run-instances --image-id ${AMI} --instance-type ${TYPE} --subnet-id ${SUBNET} --block-device-mappings "${STORAGE}" --key-name ${KEYPAIR} --security-group-ids ${GROUP} | grep INSTANCE | awk '{ print $8 }'`

#echo "instance_id: $result_id created !"

if [ "$result_id" = "" ]; then
        echo "instance_id not found ..."
        exit 1
fi

TAGS=[{\"Key\":\"Name\",\"Value\":\"${instanceName}\"}]

if [ "$instanceName" != "" ]; then
  aws ec2 create-tags --resources $result_id --tags $TAGS
fi

echo $result_id

こっちもどうぞ http://aws.aipo.com/blog/2014/10/28_163113.html