awscliからインスタンスを起動は何回か書いていますが、あれらはvpc用です。
レガシーなnovpc環境ではちょっと返り値が変わってきます。
#/bin/sh AMI=$1 instanceName=$2 awsprofile=$3 if [ "$awsprofile" = "" ]; then awsprofile=default fi KEYPAIR="{keyname}" GROUP1="{securitygroup}" GROUP2="{securitygroup}" GROUP3="{securitygroup}" USERDATA="{userdata}" if [ "$AMI" = "" ]; then echo "usage: $0 amiID name profile" exit 1 fi TYPE="m1.small" result_id=`aws ec2 run-instances --profile ${awsprofile} --image-id ${AMI} --instance-type ${TYPE} --key-name ${KEYPAIR} --security-group-ids ${GROUP1} ${GROUP2} ${GROUP3} --user-data "${USERDATA}" | grep INSTANCE | awk '{ print $7 }'` #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 --profile ${awsprofile} --resources $result_id --tags $TAGS fi echo $result_id