Skip to content

Instantly share code, notes, and snippets.

@optionalg
Forked from umihico/del_all_ec2.sh
Created June 2, 2021 05:05
Show Gist options
  • Select an option

  • Save optionalg/9dfdb6d9471b9897ab123d772450668d to your computer and use it in GitHub Desktop.

Select an option

Save optionalg/9dfdb6d9471b9897ab123d772450668d to your computer and use it in GitHub Desktop.
aws cliを使ってec2の複数を起動してセットアップしたり、落としたり。
#!/bin/bash -eu
instance_id=`aws ec2 run-instances --image-id ami-e251209a --security-group-ids sg-05a81e83dd2c1336a --count 1 --instance-type t2.micro --key-name awskey --query 'Instances[0].InstanceId'`
echo $instance_id
ip_address=`aws ec2 describe-instances --instance-ids $instance_id --query 'Reservations[0].Instances[0].PublicIpAddress'`
echo $ip_address
ssh -i 'c:/Users/umi/.ssh/awskey.pem' ec2-user@$ip_address
# ssh -i 'c:/Users/umi/.ssh/awskey.pem' ec2-user@$ip_address 'bash -s' < /c/Users/umi/GoogleDrive/code/test2.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment