Created
October 4, 2012 16:07
-
-
Save whiteley/3834636 to your computer and use it in GitHub Desktop.
ZSH function for switching ec2 regions
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
region () { | |
local _uri | |
if [[ ! -f ~/.ec2-regions || =ec2-describe-regions -nt ~/.ec2-regions ]]; then | |
ec2-describe-regions > ~/.ec2-regions | |
fi | |
_uri=$(awk -v region="${1}" '$0 ~ region { print $NF }' ~/.ec2-regions) | |
if [[ -n "${_uri}" ]]; then | |
eval "export EC2_URL=https://${_uri}" | |
else | |
echo "region \"${1}\" not found" >&2 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment