Created
November 29, 2016 09:16
-
-
Save kazu634/df38c63db960ae43fcd3ebf17fceb5ee to your computer and use it in GitHub Desktop.
AWS CLI related scripts
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
#!/usr/bin/env ruby | |
instances = `aws ec2 describe-instances | \ | |
jq -r -c '.Reservations[].Instances[] | [.InstanceId, (.Tags[]? | select(.Key == "Name")).Value, .PrivateIpAddress , .State.Name ] | @csv'` | |
instances.split().each do |instance| | |
id, name, ip, state = instance.gsub('"', '').split(',') | |
name = "NONAME" if name.empty? | |
puts "#{name}\t#{id}\t#{ip}\t#{state}" | |
end | |
exit 0 |
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 | |
# Check the # of arguments: | |
if [ $# -eq 0 ]; then | |
echo "Usage: $0 <ec2-instance-id>" | |
echo | |
echo "Or, you can specify the multiple instance ids, separated by space." | |
echo "Usage: $0 <ec2-instance-id> <ec2-instance-id> ..." | |
exit 0 | |
fi | |
# Start the ec2 instances: | |
aws ec2 start-instances --instance-ids $@ | |
exit 0 |
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 | |
# Check the # of arguments: | |
if [ $# -eq 0 ]; then | |
echo "Usage: $0 <ec2-instance-id>" | |
echo | |
echo "Or, you can specify the multiple instance ids, separated by space." | |
echo "Usage: $0 <ec2-instance-id> <ec2-instance-id> ..." | |
exit 0 | |
fi | |
# Stop the ec2 instances: | |
aws ec2 stop-instances --instance-ids $@ | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment