Skip to content

Instantly share code, notes, and snippets.

@toshihirock
Last active August 29, 2015 14:16
Show Gist options
  • Save toshihirock/6a4b987b86ef9b41d1cb to your computer and use it in GitHub Desktop.
Save toshihirock/6a4b987b86ef9b41d1cb to your computer and use it in GitHub Desktop.
#!/bin/bash -ex
# lanch
instance_id=`aws ec2 run-instances --image-id ami-hoge --instance-type t2.micro --subnet-id subnet-hoge --security-group-ids sg-hoge --key-name hogekey |jq -r '.Instances[].InstanceId'`
echo "instance_id = ${instance_id}"
sleep 5
# add tag
aws ec2 create-tags --resources ${instance_id} --tags Key=Name,Value=my-host-name
# wait unitl finishing system initialize
status=""
while [ "${status}" != "ok" ]
do
status=`aws ec2 describe-instance-status --instance-ids ${instance_id}|jq -r '.InstanceStatuses[].SystemStatus.Status'`
echo "SystemStatus = ${status}"
sleep 10
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment