These code snippets demonstrate how to build shell functions to manage AWS credentials stored in pass.
See the accompanying blog post for full details on how to use these.
These code snippets demonstrate how to build shell functions to manage AWS credentials stored in pass.
See the accompanying blog post for full details on how to use these.
# These functions can go into your `~/.bashrc`. | |
aws-activate () { | |
local profile="$1" | |
if [[ -z "$profile" ]] ; then | |
echo "Missing argument PROFILE" >&2 | |
echo "Usage: aws-activate PROFILE" >&2 | |
return 1 | |
fi | |
eval "$(pass aws-profiles/"$profile")" | |
} | |
aws-deactivate () { | |
unset AWS_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY | |
} |
# ~/.config/fish/functions/aws-activate.fish | |
function aws-activate -d 'Activate an AWS profile stored in pass' --argument profile | |
if test -z $profile | |
echo "Missing argument PROFILE" >&2 | |
echo "Usage: aws-activate PROFILE" >&2 | |
return 1 | |
end | |
pass aws-profiles/$profile | source | |
end | |
# ~/.config/fish/functions/aws-deactivate.fish | |
function aws-deactivate -d 'De-activate an AWS profile' | |
set -e AWS_PROFILE | |
set -e AWS_ACCESS_KEY_ID | |
set -e AWS_SECRET_ACCESS_KEY | |
end |