aws / git-remote-codecommit

An implementation of Git Remote Helper that makes it easier to interact with AWS CodeCommit
Apache License 2.0
271 stars 38 forks source link

git-remote-codecommit fails to recognize the new ~/.aws/config file formats created by AWS CLI v2.9.x #36

Open palaniswamy opened 1 year ago

palaniswamy commented 1 year ago

The new AWS CLI v2.9.x creates the following config file:

$ cat ~/.aws/config [profile ] sso_session = sso_account_id = sso_role_name = region = us-east-2 [sso-session mac] sso_start_url = sso_region = sso_registration_scopes = sso:account:access

Following git command fails to recognize the above new AWS Config file format:

$ git clone codecommit::<region-name>://<profile-name>@<repo-name> Cloning into ''... Traceback (most recent call last): File "/opt/homebrew/bin/git-remote-codecommit", line 33, in sys.exit(load_entry_point('git-remote-codecommit==1.16', 'console_scripts', 'git-remote-codecommit')()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/git-remote-codecommit/1.16/libexec/lib/python3.11/site-packages/git_remote_codecommit/init.py", line 176, in main context = Context.from_url(remote_url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/git-remote-codecommit/1.16/libexec/lib/python3.11/site-packages/git_remote_codecommit/init.py", line 148, in from_url credentials = session.get_credentials() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/git-remote-codecommit/1.16/libexec/lib/python3.11/site-packages/botocore/session.py", line 509, in get_credentials ).load_credentials() ^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/git-remote-codecommit/1.16/libexec/lib/python3.11/site-packages/botocore/credentials.py", line 2095, in load_credentials creds = provider.load() ^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/git-remote-codecommit/1.16/libexec/lib/python3.11/site-packages/botocore/credentials.py", line 2249, in load sso_config = self._load_sso_config() ^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/git-remote-codecommit/1.16/libexec/lib/python3.11/site-packages/botocore/credentials.py", line 2239, in _load_sso_config raise InvalidConfigError( botocore.exceptions.InvalidConfigError: The profile "" is configured to use SSO but is missing required configuration: sso_start_url, sso_region

palaniswamy commented 1 year ago

As I attempt to dig deeper, I see the following two different credentials.py

1) /opt/homebrew/Cellar/git-remote-codecommit/1.16/libexec/lib/python3.11/site-packages/botocore/credentials.py which is coming from botocore python package.

2) /opt/homebrew/Cellar/awscli/2.9.5/libexec/lib/python3.11/site-packages/awscli/botocore/credentials.py which is embedded in the awscli python package.

As you can see, I have installed awscli as well as git-remote-codecommit using homebrew and they are latest versions.

palaniswamy commented 1 year ago

The upstream botocore seem to support sso-session (https://github.com/boto/botocore/pull/2812). This "git-remote-codecommit" may just need to use the latest botocore to resolve this issue.

oliversalzburg commented 1 year ago

Why is all the AWS software so unbelievably incomplete and/or broken? You've even created a PR for this and they are still sleeping their deepest sleep...

justinmk3 commented 1 year ago

I've pinged the CodeCommit team.

climbertjh2 commented 1 year ago

@justinmk3 - any update on this issue?

I'm running into the same situation.

I have found that I get the same errors mentioned above by @palaniswamy when using a profile configured through aws configure sso and activated using aws sso login --profile <profileName>.

Further, I have set up two remotes to the same repo, one using the codecommit::... configuration and one using the https://git-codecommit..... configuration.

After setting up my gitconfig with a specific credential.https://git-codecommit...helper=!aws codecommit credential-helper --profile... $@ and credential.https://git-codecommit....usehttppath=true, I CAN access the repo using the https://git-codecommit.... remote.

Any updates on this are appreciated.

hacker65536 commented 11 months ago

When will this be handled?

athempel commented 10 months ago

It works if you use the "legacy" configuration, by not providing a session name to aws configure sso as described here:

https://docs.aws.amazon.com/cli/latest/userguide/sso-configure-profile-legacy.html

vinnymachacek commented 7 months ago

+1