I try to automate Infrastructure management with terraform in a kind of mono-repo.
In the same private repository, I store terraform modules and several terraform-configuration entry-points pointing to different products/environments. Simplified the project structure is:
src/ dev/ main.tf prod/ main.tf tf_modules module1 module2
Each environment/product reuse
tf_modules and I want to reference them as git sources. Thus, the reference looks similar to
According to terraform documentation:
Terraform installs modules from Git repositories by running
git clone, and so it will respect any local Git configuration set on your system, including credentials. To access a non-public Git repository, configure Git with suitable credentials for that repository.
When I try to run it, terraform fails to initialize modules complaining about not sufficient permissions:
email@example.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
But if checkout-action is able to pull the private repository, I hope, it should be possible to configure another action doing the same. For me, it looks like, I have to prepare local git configuration before running Terraform.
Does anyone managed to accomplish something similar? Could you point me to which direction I’d better start diving?