以下のドキュメントにあるようにクロスアカウント設定のための git config --global credential.helper
を実行したが想定した設定内容にならず、git clone
で失敗。
クロスアカウントアクセス: AccountB のリポジトリユーザー用アクション
$git config --global credential.helper "!aws codecommit credential-helper --profile MyCrossAccountAccessProfile $@"
$git clone https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/xxxx
Cloning into 'xxxx'...
git: 'credential-aws' is not a git command. See 'git --help'.
$cat .gitconfig
[credential]
helper = "aws --profile MyCrossAccountAccessProfile codecommit list-repositories --region ap-northeast-1 codecommit credential-helper --profile MyCrossAccountAccessProfile "
となり、.gitconfig がおかしい
本当は以下のドキュメントにあるように以下のようになって欲しい。
[credential]
helper = !aws codecommit credential-helper --profile=CodeCommitProfile $@
UseHttpPath = true
これは設定したのが Bash だったので展開されてしまったためようだった。
What is $@ in Bash? [duplicate]
実は CodeCommit のドキュメントにも記載があったのだが、二重引用符ではなく単一引用符を使用すれば OK.
$git config --global credential.helper '!aws codecommit credential-helper --profile MyCrossAccountAccessProfile $@'
Windows のコマンドラインではなく Bash エミュレーターを使用している場合は、二重引用符ではなく単一引用符を使用する必要があります。