Last active
August 29, 2015 14:16
-
-
Save toshihirock/6a4b987b86ef9b41d1cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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