Created
July 21, 2020 13:45
-
-
Save miketheartguy/aa2017d2bf1a18770846808cf4deeb03 to your computer and use it in GitHub Desktop.
AWS and CodeCommit Configure for Multiple Accounts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.aws/config | |
[profile account1] | |
region = us-east-2 | |
[profile account2] | |
region = us-east-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.aws/credentials | |
[account1] | |
aws_access_key_id = ACCESS-KEY-ID-1 | |
aws_secret_access_key = SECRET-KEY-ID-1 | |
[account2] | |
aws_access_key_id = ACCESS-KEY-ID-2 | |
aws_secret_access_key = SECRET-KEY-ID-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.ssh/config | |
Host account1 | |
Hostname git-codecommit.us-east-1.amazonaws.com | |
User SSH-KEY-ID-1 | |
IdentityFile ~/.ssh/id_rsa | |
Host account2 | |
Hostname git-codecommit.us-east-1.amazonaws.com | |
User SSH-KEY-UID-2 | |
IdentityFile ~/.ssh/id_rsa |
For CDK AWS_PROFILE=account1 cdk ls
works but cdk ls --profile account1
doesn't?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generate AWS config:
aws configure --profile account1
Generate Git Config:
git config --local credential.helper '!aws codecommit credential-helper --profile account1 $@'
Clone Repo (replace URL with account hostname):
git clone ssh://account1/v1/repos/repo-name