Created
December 19, 2018 02:03
-
-
Save scottarthur/b99072a30598a1e3f5504cf8d2136f43 to your computer and use it in GitHub Desktop.
PCSK AWS key clipboard ~> ~./aws/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
function ccgcp () { | |
# Don't continue unless clipboard has the creds export command in it | |
if [[ ! $(pbpaste) =~ "export AWS_ACCESS_KEY_ID.*" ]]; then | |
echo "Clipboard didn't have credentials" | |
return | |
fi | |
$(pbpaste) | |
export AWS_CODECOMMIT_PROFILE=Terraform-GCP | |
# remove last three lines of file (old creds) | |
for i in {0..2}; do | |
sed -i '' -e '$ d' ~/.aws/credentials | |
done | |
# Grab new creds from env, lowercase the variable names and append to creds file | |
for line in $(env | grep AWS | egrep "KEY|TOKEN"); do | |
echo $line | gsed -e 's/\([^=]*\)=/\L\1=/' >> ~/.aws/credentials | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment