Last active
September 9, 2021 19:55
-
-
Save gfranxman/94cece5ddd4d99aa2f97bea32ca0aa34 to your computer and use it in GitHub Desktop.
AWS cred juggling, credset command I've been using for years and awsenv which keeps everything off the filesystem and only in memory
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 | |
CRED=~/.aws/${1}.credentials | |
if [ -f $CRED ] | |
then | |
echo setting aws creds to $1 | |
ln -f -s $CRED ~/.aws/credentials | |
else | |
echo sorry, choose from | |
credlist | |
fi | |
CONFIG=~/.aws/${1}.config | |
if [ -f $CONFIG ] | |
then | |
echo setting aws config to $1 | |
ln -f -s $CONFIG ~/.aws/config | |
else | |
ln -f -s ~/.aws/us-east-1.config ~/.aws/config | |
fi | |
echo | |
echo -n 'currently: ' | |
readlink ~/.aws/credentials | xargs basename -s .credentials |
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
# logs into $WORKPLACE for 1password | |
# then looks up the record in the default vault | |
# and exports any AWS_* values to the current shell | |
awsenv() { | |
eval $(op signin $WORKPLACE) | |
op get item $1 | |
$(op get item $1 | jq -r '.details.sections[].fields|.[]?|select(.t|startswith("AWS_"))|.t+"="+.v' | sed 's/^/export /; s/\n/ /g') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment