Where do I configure my AWS "Code Commit" credentials in PyCharm? [Elastic Beanstalk code pipeline]

Viewed 1824

I'm in the process of deploying/pushing (GitHub) a Python/Django application with Amazon RDS PostgreSQL db to AWS Elastic Beanstalk via Code Commit from PyCharm.

I uploaded my server certificate (having SSL issues, most can disregard the --no-verify-ssl):

aws iam upload-server-certificate --server-certificate-name CSC --certificate-body file://public.pem --private-key file://private.pem --no-verify-ssl

etc. Worked fine.

eb init Set-up Code Commit, SSH:

Do you wish to continue with CodeCommit? (y/N) (default is n): y

Enter Repository Name
(default is "origin"): 
Successfully created repository: origin

Enter Branch Name
***** Must have at least one commit to create a new branch with CodeCommit *****
(default is "master"): 
Username for 'https://github.com/mygitusername/myapp.git': user@email.com
Password for 'https://user@email.com@github.com/mygitusername/myapp.git': 
Successfully created branch: master
Do you want to set up SSH for your instances?
(Y/n): y

Select a keypair.
1) mykeypairname
...

Worked fine.

eb create Setup environment, etc.

Enter Environment Name
(default is eb-myapp-dev): 
Enter DNS CNAME prefix
(default is eb-myapp-dev): 
Select a load balancer type
1) classic
2) application
3) network
(default is 2): 


Would you like to enable Spot Fleet requests for this environment?
(y/N): n
Starting environment deployment via CodeCommit
...

Worked fine.

Then I go to PyCharm to commit changes, then push in Git, I'm asked for my Code Commit "credentials". I think, my AWS access key ID and secret key? I used/confirmed via aws configure these are accurate. Maybe but there's an option for "Password helper" so I click that. Now I'm unable to get back to that screen to enter my credentials, or at least try. I keep getting:

Push failed
Unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/origin/': The requested URL returned error: 403

How can I configure my AWS "Code Commit" credentials in PyCharm?

1 Answers

Original Poster, here. Here is how I resolved the problem.

  1. Run these commands to add the AWS credential helper to ~/.gitconfig:
git config --global credential.helper '!aws codecommit credential-helper $@' credential.UseHttpPath true
git config --global credential.helper '!aws --profile CodeCommitProfile codecommit credential-helper $@' 
  1. Run git config --global --edit to verify your input.
  2. Open Keychain. Add '+' git-codecommit.us-east-2.amazonaws.com and your Access Key ID in username and Secret Key in password. Save and close.
  3. Delete the rule you just created in Keychain for git-codecommit.us-east-2.amazonaws.com.
  4. Git is set to use the Keychain Access utility on macOS, which may cause problems with the Amazon Code Commit service. Change this by running the following command:
git config --system --unset credential.helper

You should get something back like, either: "no value exists" or "removed."

  1. Finally, I followed these AWSCodeCommitPowerUser instructions: https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-gc.html#setting-up-gc-account.

I'm not sure which one of those actually fixed my problem, but after all this, I opened PyCharm and did a commit/push. Now it works.

Related