Skip to content

Instantly share code, notes, and snippets.

@scottarthur
Created December 19, 2018 02:03
Show Gist options
  • Save scottarthur/b99072a30598a1e3f5504cf8d2136f43 to your computer and use it in GitHub Desktop.
Save scottarthur/b99072a30598a1e3f5504cf8d2136f43 to your computer and use it in GitHub Desktop.
PCSK AWS key clipboard ~> ~./aws/credentials
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