Last active
August 29, 2015 14:00
-
-
Save oremj/1d62e6c0354ccf3877d7 to your computer and use it in GitHub Desktop.
Switch between encrypted AWS environments.
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
# -*- mode: shell-script -*- | |
# source this file from your shell's rc file | |
activate_aws_env() { | |
AWS_ENV=$1 | |
ENV_FILE="${HOME}/Dropbox/awsenvs/${AWS_ENV}.gpg" | |
if [ ! -f "$ENV_FILE" ]; then | |
echo "$ENV_FILE" does not exist. | |
return | |
fi | |
OUT=$(gpg -d "$ENV_FILE") | |
eval "$OUT" | |
} |
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
#!/bin/bash | |
set -e | |
set -o nounset | |
AWS_ENV=$1 | |
mkdir -p "${HOME}/Dropbox/awsenvs" | |
ENV_FILE="${HOME}/Dropbox/awsenvs/${AWS_ENV}.gpg" | |
if [[ -f "$ENV_FILE" ]]; then | |
echo "env already exists" | |
exit 1 | |
fi | |
read -p "Key id: " AWS_ACCESS_KEY_ID | |
read -p "Key secret: " AWS_SECRET_ACCESS_KEY | |
gpg -c -o "$ENV_FILE" <<ENVDOC | |
export AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} | |
export AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} | |
ENVDOC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment