Skip to content

Instantly share code, notes, and snippets.

@aheissenberger
Created May 4, 2019 14:43
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 aheissenberger/151c82725107ebb34e343f497aebc8a6 to your computer and use it in GitHub Desktop.
Save aheissenberger/151c82725107ebb34e343f497aebc8a6 to your computer and use it in GitHub Desktop.
Wrapper for AWS CodeCommit git credential helper to fix problem with MacOS keystore
#!/bin/bash
# SETUP: add to local git config:
# git config --local credential.helper '!~/bin/awsCredentialHelperOSX AWS_PROFILE'
# replace AWS_PROFILE with the relevant profile name, replace "~/bin/" with path to this file
aws_profile="$1"
shift
# get aws_access_key_id for aws_profile
aws_access_key_id=$(sed -n '/^[ \t]*\[${aws_profile}\]/,/\[/s/^[ \t]*aws_access_key_id[ \t]*=[ \t]*//p' ~/.aws/credentials)
security -q delete-internet-password -a "${aws_access_key_id}" >/dev/null 2>&1
/usr/local/bin/aws --profile "${aws_profile}" codecommit credential-helper $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment