Last active
June 2, 2021 05:05
-
-
Save umihico/f859b0840ca7fc39121cd7a15c63c99b to your computer and use it in GitHub Desktop.
aws cliを使ってec2の複数を起動してセットアップしたり、落としたり。
This file contains 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 -eu | |
all_ids=`aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --output text | tr '\t' ' '` | |
echo terminating... $all_ids | |
aws ec2 terminate-instances --instance-ids $all_ids --query "TerminatingInstances[].CurrentState[].Name" --output text |
This file contains 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 -eu | |
aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --filters Name=instance-state-name,Values=running --output text | tr '\t' ' ' |
This file contains 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 -eu | |
aws ec2 describe-instances --query "Reservations[].Instances[].PublicIpAddress" --filters Name=instance-state-name,Values=running --output text | tr '\t' ' ' |
This file contains 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
instance_id=$1 | |
aws ec2 stop-instances --instance-ids $instance_id | |
aws ec2 wait instance-stopped --instance-ids $instance_id | |
# aws ec2 start-instances --instance-ids $instance_id | |
until aws ec2 start-instances --instance-ids $instance_id; do | |
echo start-instances failed | |
sleep 1 | |
done | |
aws ec2 wait instance-running --instance-ids $instance_id |
This file contains 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 -eu | |
ip_address=$1 | |
git_password=$2 | |
dirname="$( cd "$(dirname "$0")" ; pwd -P )" | |
until ssh -o StrictHostKeyChecking=no -i c:/Users/umi/.ssh/awskey.pem ec2-user@$ip_address bash -s < $dirname/setup.sh $git_password ; do | |
echo ssh failed | |
sleep 1 | |
done |
This file contains 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 -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'` | |
instance_id=`echo $instance_id | sed 's/"//g'` | |
aws ec2 wait instance-running --instance-ids $instance_id | |
ip_address=`aws ec2 describe-instances --instance-ids $instance_id --query 'Reservations[0].Instances[0].PublicIpAddress'` | |
ip_address=`echo $ip_address | sed 's/"//g'` | |
echo $ip_address |
This file contains 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 | |
git_password=$1 | |
export git_password | |
sudo -E su | |
yum -y update | |
yum -y install gcc gcc-c++ make git openssl-devel bzip2-devel zlib-devel readline-devel sqlite-devel tmux | |
cd /home/ec2-user/ | |
git clone https://gist.github.com/0806b81a2c5143ee3c0ae843f7c676fc.git setup_aws | |
cd /home/ec2-user/setup_aws | |
for file in `\find . -name '*.sh'`; do sed -i 's/\r//' $file; done | |
chmod +x ./*.sh | |
# source /home/ec2-user/setup_aws/setup_font.sh | |
source /home/ec2-user/setup_aws/setup_timezone.sh | |
source /home/ec2-user/setup_aws/setup_python.sh | |
source /home/ec2-user/setup_aws/setup_selenium.sh | |
source /home/ec2-user/setup_aws/setup_proxy.sh | |
source /home/ec2-user/setup_aws/setup_git_service.sh | |
source /home/ec2-user/setup_aws/setup_tor.sh |
This file contains 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment