Skip to content

Instantly share code, notes, and snippets.

@dvdbng
Created April 2, 2020 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvdbng/c72e36564ab959b142db42e11fdcc587 to your computer and use it in GitHub Desktop.
Save dvdbng/c72e36564ab959b142db42e11fdcc587 to your computer and use it in GitHub Desktop.
Set AWS credentials from pass store
#!/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