https
module "private_module" {
source = "git::https://github.com/private-org/private-repo.git?ref=${branch or tag}"
...
}
CIでhttps経由でmoduleを使う場合はtokenが必要になるため,gitの設定でtokenを設定
$ git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/private-org".insteadOf "https://github.com/private-org"
ssh
module "private_module" {
source = "git::git@github.com:private-org/private-repo.git//backend?ref=${branch or tag}"
...
}
sshにしておきつつ、CIだけはtokenを使うようなケースではこうするとよい
$ git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/private-org".insteadOf "ssh://git@github.com/private-org"