首页 > 解决方案 > 在 PyCharm 中的何处配置我的 AWS“代码提交”凭证?[Elastic Beanstalk 代码管道]

问题描述

我正在通过 PyCharm 的代码提交将带有 Amazon RDS PostgreSQL db 的 Python/Django 应用程序部署/推送(GitHub)到 AWS Elastic Beanstalk。

我上传了我的服务器证书(有 SSL 问题,大多数人可以忽略 --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

等工作正常。

eb init设置代码提交,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
...

工作得很好。

eb 创建安装环境等。

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
...

工作得很好。

然后我去 PyCharm 提交更改,然后推入 Git,我被要求提供我的代码提交“凭据”。我想,我的 AWS 访问密钥 ID 和密钥?我通过aws configure这些使用/确认是准确的。也许可以,但有一个“密码助手”选项,所以我点击它。现在我无法返回该屏幕输入我的凭据,或者至少尝试一下。我不断得到:

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

如何在 PyCharm 中配置我的 AWS“代码提交”凭证?

标签: amazon-web-servicespycharmamazon-elastic-beanstalkaws-codecommit

解决方案


原始海报,在这里。这是我解决问题的方法。

  1. 运行以下命令将 AWS 凭证帮助程序添加到 ~/.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. 运行 gitconfig --global --edit以验证您的输入。
  2. 打开钥匙串。在用户名中添加“+” git-codecommit.us-east-2.amazonaws.com和您的访问密钥 ID,在密码中添加密钥。保存并关闭。
  3. 删除您刚刚在钥匙串中为git-codecommit.us-east-2.amazonaws.com创建的规则。
  4. Git 设置为在 macOS 上使用 Keychain Access 实用程序,这可能会导致 Amazon Code Commit 服务出现问题。通过运行以下命令来更改它:
git config --system --unset credential.helper

您应该得到类似的东西:“不存在价值”或“已删除”。

  1. 最后,我遵循了这些 AWSCodeCommitPowerUser 说明:https ://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-gc.html#setting-up-gc-account 。

我不确定其中哪一个真正解决了我的问题,但毕竟,我打开了 PyCharm 并执行了提交/推送。现在它起作用了。


推荐阅读