Created
December 6, 2017 18:18
-
-
Save rberrelleza/9b38ea06ba83f8b88fac9b144d59e100 to your computer and use it in GitHub Desktop.
script to launch an AMI
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 | |
output=$(aws ec2 run-instances --image-id $1 --instance-type m3.large --key-name YOUR_KEY --security-group-ids YOUR_SG --subnet-id YOUR_SUBNET --associate-public-ip-address --block-device-mapping '[{"DeviceName": "/dev/sda1","Ebs":{"VolumeSize":60}}]') | |
instance=$(echo $output | grep -o '\"InstanceId\": "i-........\"' | grep -o i-........ ) | |
tag=$(whoami)-$(date +"%Y-%m-%d_%H-%M-%S") | |
sleep 5 | |
aws ec2 create-tags --resources $instance --tags Key=Name,Value=$tag | |
echo $instance% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment