Created
November 14, 2008 18:57
-
-
Save rcarver/25047 to your computer and use it in GitHub Desktop.
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
# Set environment variables authorizing AWS for a specific account. Data is stored in: | |
# ~/.amazon_keys_[account] | |
# ~/.ec2_[account]/pk-*.pem | |
# ~/.ec2_[account]/cert-*.pem | |
# ~/.ec2_[account]/id_rsa-* | |
function aws { | |
export AWS_CURRENT=$1 | |
# AWS | |
if [[ -f "$HOME/.amazon_keys_$1" ]]; then | |
source "$HOME/.amazon_keys_$1"; | |
else | |
echo "No Amazon keys for $1" | |
fi | |
# EC2 | |
export EC2_HOME=~/bin/ec2-api-tools-1.3-26369 | |
export PATH=$PATH:$EC2_HOME/bin | |
if [[ -d "$HOME/.ec2_$1" ]]; then | |
export EC2_PRIVATE_KEY=`ls $HOME/.ec2_$1/pk-*.pem`; | |
export EC2_CERT=`ls $HOME/.ec2_$1/cert-*.pem`; | |
export EC2_KEYPAIR=`ls $HOME/.ec2_$1/id_rsa-*`; | |
export EC2_KEYPAIR_NAME=`echo $EC2_KEYPAIR | sed -E 's/.*id_rsa-(.*)/\1/'`; | |
else | |
echo "No EC2 keys for $1" | |
fi | |
} | |
# Boot an EC2 instance with the current keypair | |
function ec2boot { | |
ec2-run-instances $1 -k $EC2_KEYPAIR_NAME | |
} | |
# ssh into an instance with the current keypair. | |
function ec2ssh { | |
ssh -i $EC2_KEYPAIR root@$1 | |
} | |
# Display the current AWS account set via aws. | |
alias awswho='echo $AWS_CURRENT' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment