Reputation: 479
I was able to pull and/or push updated from my AWS CodeCommit repository until I reinstalled aws-cli
.
I tried all the suggested solutions I could find but nothing seems to work.
I am working on Ubuntu 21.10 and installed:
$ aws --v
aws-cli/1.19.1 Python/3.9.7 Linux/5.13.0-41-generic botocore/1.20.0
git version 2.32.0
The error I am getting is:
fatal: unable to access 'https://git-codecommit.eu-west-2.amazonaws.com/v1/repos/myrepo/': The requested URL returned error: 403
It used to ask me for my username and password, but after my experiments to solve the issue it stopped asking for my credentials completely. Either way I confirmed that I was using the correct credentials. Also, I do have the necessary permissions at AWS. I was successfully pulling and pushing updates until a few hours ago.
The aws credential helper is set as recommended by most solutions online. More specifically my .gitconfig
file looks like this:
[user]
name = My_name
email = My_email
[credential]
helper = !aws codecommit credential-helper $@
UseHttpPath = true
Additionally, I set up correctly (with the correct region) the $ aws configure
configuration.
Listing $ git config --list --show-origin
I am getting:
file:/etc/gitconfig user.email=My_email
file:/home/f_user/.gitconfig user.name=My_name
file:/home/f_user/.gitconfig user.email=My_email
file:/home/f_user/.gitconfig credential.helper=!aws codecommit credential-helper $@
file:/home/f_user/.gitconfig credential.usehttppath=true
Honestly I have no idea what else to try, any help would be appreciated!
EDIT: The way I resolved the issue is:
I am not sure what was the part that solved it, probably the first step.
Upvotes: 15
Views: 48718
Reputation: 1
I had this problem, when following an AWS tutorial, in the "Enable Web hosting with the AWS Amplify console" step. At this stage, when deploying to AWS Amplify via CodeCommit, the build reported this error. After a lot of research, I understood that for this process, it is necessary to attach a "service function" to the application.
Follow this procedure to create this "function" and how to attach it to the application.
https://docs.aws.amazon.com/pt_br/amplify/latest/userguide/how-to-service-role-amplify-console.html
Upvotes: -1
Reputation: 1
The 403 Forbidden error comes when IAM users do not have the necessary permissions to access the AWS CodeCommit repository. We need to get HTTPS Git credentials for AWS CodeCommit. This works for me
By using these creds you able to clone the repo.
Upvotes: -1
Reputation: 7
You can just add the AWSCodeCommitPowerUser Permission Policy to your User and that worked for me.
Upvotes: -1
Reputation: 171
I have been struggling with this issue for months. Today I discovered it was my setup.
Which is:
Running a Development Container in VS Code, on a Windows machine, Docker with WSL integration. I followed all AWS codecommit setup commands and ofcourse these:
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
But a git clone of any repo still resulted in: The requested URL returned error: 403
If you work with VS Code Development Containers, there are two locations where some gitconfig is stored:
/etc/gitconfig
/home/node/.gitconfig
(setup is a nodejs dev-container ie. see last line)
If you run:
git config --list --show-origin
Take note of these lines:
file:/etc/gitconfig credential.helper=credential.helper=!aws codecommit credential-helper $@
file:/home/node/.gitconfig credential.helper=!aws codecommit credential-helper $@
In my case, the content after the =
was different. The fix was to edit /etc/gitconfig
manually and give the helper
key the correct value.
Upvotes: 2
Reputation: 1
For windows, if the problem still exists "fatal: unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/RepositoryName': The requested URL returned error: 403" Try fixing your environment variables in windows. If the credentials are changed for clonning the repos, the environment is led with the old set of region and key values.
Upvotes: -1
Reputation: 2484
Follow the steps under the section called "Git for macOS: I configured the credential helper successfully, but now I am denied access to my repository (403)" under the below documentation.
https://docs.aws.amazon.com/codecommit/latest/userguide/troubleshooting-ch.html
Upvotes: 0
Reputation: 11
I was also facing a similar kind of issue,
fatal: unable to access 'https://git-codecommit.ap-south-1.amazonaws.com/v1/repos/sunday-demo/':
The requested URL returned error: 403
Solution :
Issue the below two commands so it will promote credential windows.
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
Upvotes: 1
Reputation: 91
If you are a mac user. just type code ~/.gitconfig
and then paste the following if the credential section missing.
[credential]
helper = !aws codecommit credential-helper $@
UseHttpPath = true
Upvotes: 9
Reputation: 977
If you're using Mac go to keychain access, look up codecommit and delete the stored key.
Upvotes: 23
Reputation: 21
The resolution for me was to reinstall git and deselect the git credential helper.
Upvotes: 2
Reputation: 176
Just delete credentials as below and next time pop-up window prompt for credentials Steps to delete your Credential Manager
Control Panel Select "Credential Manager" Under Generic Credential, delete the appropriate Git Credential.
Upvotes: 15
Reputation: 479
The way I resolved the issue after all is:
Uninstalled aws client from my system and re installed and configured it from scratch.
I cloned my IAM account and gave it Full AWSCodeCommit access.
I am not sure what was the part that solved it, probably the first step since after I reinstalled everything I was prompted again to use my credentials.
Upvotes: 1
Reputation: 1324337
Double-check your AWS managed policies for for CodeCommit.
If your IAM User has switched to ForceMultiFactorAuthentication
as policy, you would need to use a token, not your password.
Locally, check what password is stored by your credential manager:
printf "protocol=https\nhost=git-codecommit.eu-west-2.amazonaws.com"|aws codecommit credential-helper get
Upvotes: 2