1. Help Center
  2. Troubleshooting

Error: Failed to download module

I get an error when using env0 with my existing Terraform code

If you are seeing an error something similar to: "Error: Failed to download module" this error message is coming from Terraform.
Typically, this happens when you are referencing a module with a git source.

If the git source is using " https" - then you need to configure a git token in order for Terraform (or Terragrunt).  e.g. 

module "vpc" { 

  source = "git::https://example.com/vpc.git"

}

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

source: https://www.terraform.io/language/modules/sources#generic-git-repository

 

Alternatively, if the git source is using "ssh" - then you need to configure an SSH key and add it to your template.  See https://docs.env0.com/docs/ssh-keys for more details.

e.g. 

module "storage" { 

  source = "git::ssh://username@example.com/storage.git"

}