deploy.sh git push not working for AWS Identity Centre federated authentication using named profiles
reidca opened this issue · 1 comments
Describe the bug
When running the deploy.sh script provided the code commit command "git push origin main" errors.
To Reproduce
Steps to reproduce the behavior:
- Setup the parameters.sh file using AWS SSO profiles (defined in the ~/.aws/config file) for the ORG_MASTER_PROFILE and TEAM_ACCOUNT_PROFILE
- Run the deploy.sh script
- Error "fatal. repository not found" error is returned
Expected behavior
The script should push the content into the Code Commit repo successfully
Desktop (please complete the following information):
- OS: Ubuntu 22.04
git version: 2.34.1
Additional context
After reading the AWS documentation, I discovered this page: https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-git-remote-codecommit.html#:~:text=To%20clone%20the%20same%20repository%20using%20a%20profile%20named%20CodeCommitProfile%3A
In this page it mentions how to use a named profile for the git command:
git clone codecommit://CodeCommitProfile@MyDemoRepo my-demo-repo
To fix this, I updated the command in the deploy.sh
FROM:
git remote add origin codecommit::$REGION://team-idc-app
TO:
git remote add origin codecommit::$REGION://$TEAM_ACCOUNT_PROFILE@team-idc-app
This has resolved the problem.
I think I discovered why this happened - it seems I had the environment variable AWS_DEFAULT_PROFILE set pointing to a totally different profile. This caused issues elsewhere so it may have also caused this. Although I have read that AWS_PROFILE should take precedence over AWS_DEFAULT_PROFILE so I am not 100% certain. Either way, it might be useful for the documentation to mention that the user should check this prior to running the deploy.sh script.