Terraform remote modules with git ssh

Is it possible to use remote modules with the Terraform steps that rely on modules in private git repositories, using an SSH key pair (such as with an ssh-agent)? We use modules with a git source like the following, and Terraform needs access to git using SSH:

module "some_module" {
  source = "git@github.com:myorg/my-terraform-modules.git//submodule"
}
1 Like

Hi Jeremy,

From my research it seems to be possible, have a read of https://github.com/hashicorp/terraform/issues/18541#issuecomment-416369712
Also, the terraform doco - https://www.terraform.io/docs/modules/sources.html#generic-git-repository

Regards
John

Yes, this is what we are doing outside of Octopus now. My question is whether Octopus provides a way to manage the SSH Agent config used during the Terraform steps, or whether we will have to manually configure static SSH configurations and agents on all Octopus workers.

Ideally, what I would like to see, is the ability to load SSH key pairs from Octopus into an SSH agent running in the same context as the Terraform Octopus steps.

Hi Jeremy,

Unfortunately this is not currently supported by Octopus, so you will have to do your second suggestion (manually configure SSH on the workers).

If you would like to see this added to Octopus, I would suggest raising an issue on our UserVoice forum.

Regards,
Tom

we are starting with terraform on octopus, and this is definitely something we could use. Now we have to modify the workers manually or from another place.