Created
April 2, 2020 17:06
-
-
Save dvdbng/c72e36564ab959b142db42e11fdcc587 to your computer and use it in GitHub Desktop.
Set AWS credentials from pass store
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
#!/bin/bash | |
# Usage awsenv enviromnent command... | |
search="$1" | |
shift | |
file=$(find "$HOME"/.password-store/AWS | grep "$search.*/AKIA.*gpg$") | |
if [[ x"$file" = x ]]; then | |
echo "Could not find a AWS key at $search" >&2 | |
exit 1 | |
fi | |
entry=$(realpath --relative-to="$HOME"/.password-store "${file%.gpg}") | |
AWS_ACCESS_KEY_ID="$(basename "$entry")" | |
AWS_SECRET_ACCESS_KEY="$(pass "$entry")" | |
export AWS_ACCESS_KEY_ID | |
export AWS_SECRET_ACCESS_KEY | |
"$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment