Created
July 14, 2017 18:44
-
-
Save cynicXer/638be8a13fe2b361564eb2abb7529e87 to your computer and use it in GitHub Desktop.
More AWS Bash Stuffs
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
for region in `aws ec2 describe-regions --output text | cut -f3` | |
do | |
echo -e "\nListing Instances in region:'$region'..." | |
aws ec2 describe-instances --region $region | jq '.Reservations[] | ( .Instances[] | {state: .State.Name, name: .KeyName, type: .InstanceType, key: .KeyName})' | |
done |
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
keypair=$USER # or some name that is meaningful to you | |
publickeyfile=$HOME/.ssh/id_rsa.pub | |
regions=$(aws ec2 describe-regions \ | |
--output text \ | |
--query 'Regions[*].RegionName') | |
for region in $regions; do | |
echo $region | |
aws ec2 import-key-pair \ | |
--region "$region" \ | |
--key-name "$keypair" \ | |
--public-key-material "file://$publickeyfile" | |
done |
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
keypair=$USER # or some name that is meaningful to you | |
publickeyfile=$HOME/.ssh/id_rsa.pub | |
regions=$(aws ec2 describe-regions \ | |
--output text \ | |
--query 'Regions[*].RegionName') | |
for region in $regions; | |
echo $region | |
aws ec2 delete-key-pair \ | |
--region "$region" \ | |
--key-name "$keypair" \ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment