Skip to content

Instantly share code, notes, and snippets.

@dm
Last active August 29, 2015 14:14
Show Gist options
  • Save dm/5ed77663c48a8e5c5f28 to your computer and use it in GitHub Desktop.
Save dm/5ed77663c48a8e5c5f28 to your computer and use it in GitHub Desktop.
AWS CLI for multiple clients
# in ~/.dotfiles/zsh/alias.zsh
alias aws='client=$1 source ~/.dotfiles/bin/aws.zsh $client'
#!/bin/zsh
# in ~/.dotfiles/bin/aws.zsh
export EC2_REGION='eu-west-1'
case "$1" in
"cl1")
export AWS_ACCESS_KEY='ACC1'
export AWS_SECRET_KEY='KEY1'
export AWS_ACCOUNT='Client 1'
;;
"cl2")
export AWS_ACCESS_KEY='ACC2'
export AWS_SECRET_KEY='KEY2'
export EC2_REGION='us-west-2' # Override default region
export AWS_ACCOUNT='Client 2'
;;
"cl3")
export AWS_ACCESS_KEY='ACC3'
export AWS_SECRET_KEY='KEY3'
export AWS_ACCOUNT='Client 3'
;;
*)
export AWS_ACCOUNT="No account"
;;
esac
echo "$AWS_ACCOUNT is active."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment