Skip to content

Instantly share code, notes, and snippets.

@whiteley
Created October 4, 2012 16:07
Show Gist options
  • Save whiteley/3834636 to your computer and use it in GitHub Desktop.
Save whiteley/3834636 to your computer and use it in GitHub Desktop.
ZSH function for switching ec2 regions
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