Terraform: Module not found, may need to be downloaded using 'terraform get'

Created on 8 Sep 2016  ·  20Comments  ·  Source: hashicorp/terraform

After updating to Terraform 0.7.3, I am getting the following error when running terraform plan:

Error downloading modules: module REDACTED: not found, may need to be downloaded using 'terraform get'

This issue doesn't seem to occur in Terraform 0.7.2. I will work on a MWE to reproduce this issue.

bug core

Most helpful comment

Happened to me too, had to delete old modules in .terraform/modules to get a terraform get -update working again.

Does terraform encode something version-specific in its modules, which makes this an expected behavior? I don't remember having to do this between 0.7.1 and 0.7.2, but definitely between 0.7.2 and 0.7.3.

All 20 comments

> TF_LOG=debug terraform get -update=true $(readlink templates)
2016/09/08 12:58:54 [INFO] Terraform version: 0.7.3  0dd7c657d6d60d2e7392b66ae6f74fb84582cab9
2016/09/08 12:58:54 [INFO] CLI args: []string{"/usr/local/bin/terraform", "get", "-update=true", "../../../templates/REDACTED"}
2016/09/08 12:58:54 [DEBUG] Detected home directory from env var: /home/josh
2016/09/08 12:58:54 [DEBUG] Detected home directory from env var: /home/josh
2016/09/08 12:58:54 [DEBUG] Attempting to open CLI config file: /home/josh/.terraformrc
2016/09/08 12:58:54 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2016/09/08 12:58:54 [DEBUG] Detected home directory from env var: /home/josh
2016/09/08 12:58:54 [INFO] state modified during read or write. incrementing serial number
Get: file:///home/josh/workspace/REDACTED/src/modules/iam (update)
Get: file:///home/josh/workspace/REDACTED/src/modules/iam/configuration (update)
Get: file:///home/josh/workspace/REDACTED/src/modules/iam/ssl_certificates (update)
Get: file:///home/josh/workspace/REDACTED/src/modules/instance (update)
Get: file:///home/josh/workspace/REDACTED/src/modules/user_data (update)
2016/09/08 12:58:54 [DEBUG] plugin: waiting for all plugin processes to complete...

> TF_LOG=debug terraform plan templates/
2016/09/08 12:59:36 [INFO] Terraform version: 0.7.3  0dd7c657d6d60d2e7392b66ae6f74fb84582cab9
2016/09/08 12:59:36 [INFO] CLI args: []string{"/usr/local/bin/terraform", "plan", "templates/"}
2016/09/08 12:59:36 [DEBUG] Detected home directory from env var: /home/josh
2016/09/08 12:59:36 [DEBUG] Detected home directory from env var: /home/josh
2016/09/08 12:59:36 [DEBUG] Attempting to open CLI config file: /home/josh/.terraformrc
2016/09/08 12:59:36 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2016/09/08 12:59:36 [DEBUG] Detected home directory from env var: /home/josh
2016/09/08 12:59:36 [INFO] state modified during read or write. incrementing serial number
2016/09/08 12:59:36 [DEBUG] plugin: waiting for all plugin processes to complete...
Error downloading modules: module REDACTED: not found, may need to be downloaded using 'terraform get'

Happened to me too, had to delete old modules in .terraform/modules to get a terraform get -update working again.

Does terraform encode something version-specific in its modules, which makes this an expected behavior? I don't remember having to do this between 0.7.1 and 0.7.2, but definitely between 0.7.2 and 0.7.3.

This is mentioned in the CHANGELOG as a slight BC-change in 0.7.3: we changed some internal structures requiring you to run terraform get again.

Thanks for the feedback. Admittedly, I didn't read the changelog. But I did run terraform get before getting this error message. I'll play around a bit more later today and see if I can reproduce again.

Yeah, this definitely doesn't seem to be working as expected. I ran git clean -f -d -x (which removed a whole bunch of .terraform/modules/ files) and I am still seeing the original error.

I'm not sure if it's relevant, but we are using relative paths for our modules.

module "module" {
  source = "../../../modules/some_module"
}

If I revert #8398 then I no longer get an error.

I've created a small repository that can be used to reproduce the issue, see https://github.com/joshuaspence/terraform-issue8724-test. To reproduce the error with Terraform 0.7.3, follow these steps:

git clone https://github.com/joshuaspence/terraform-issue8724-test
cd environments/production
rm -rf .terraform/
terraform get $(readlink -f templates/)
terraform plan templates/

It could be our use of symlinks that is causing the issue. We use symlinks so that we can use the same set of Terraform files to produce multiple identical environments (eg. dev, staging and production).

It looks like I can't reopen this issue but it would be appreciated if someone else could re-open it for me.

reopened

Relevant comment/commit here that introduced this: https://github.com/hashicorp/terraform/pull/8398#issuecomment-246211863

I think most importantly in addition to simply reverting we'll need to add regression testing around this since I was able to get the above commit in without any failing tests.

We also use relative paths to (many) modules here, and have not been able to get 0.7.3 to run in Atlas. Nothing I've tried yet seems to make a difference, including deleting my existing local modules before doing a get/push.

For the moment I've reverted to 0.7.2 across the board.

UPDATE: I just tried 0.7.4 and it is displaying the same behavior as 0.7.3 was re: existing environments in Atlas. Not fixed...

https://github.com/hashicorp/go-getter/issues/28 seems to be the root issue here, causing an invalid module path when starting from a relative symlink.

Also confirming an issue in 0.7.3 with relative paths to modules. Using 0.7.2 locally and setting Atlas to run the environment with 0.7.2 resolved the issue for now.

Ah hah, @jbardin has a nice fix up that looks great.

For some reason, Terraform 0.7.3 was working for some people in our company but not for others. As a result, I am now unable to use Terraform 0.7.2 (because the state file was last updated with Terraform 0.7.3) and also unable to use Terraform 0.7.3 (because of this issue). Is there any chance of cutting a new release soon?

I see that this has been closed, but it doesn't seem to be included in the CHANGELOG for version 0.7.4 or 0.7.5, nor has the behavior changed. Has this not been included in a release yet?

I'm using terraform v0.10.7 on osx and I am getting the same error. Is this expected?

(srossross-mac3 tfexample •‿•) terraform apply envs/development/
Failed to load root config module: Error loading modules: module child: not found, may need to be downloaded using 'terraform get'
# File envs/development/main.tf
module "child" {
  source = "../../modules/child"
  memory = "10G"
}

This seems like it will be less than ideal when I am developing on my child module. Will I need to run terraform get then terraform apply each time I make a change?

@srossross-tableau try running terraform get

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings