Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local-path modules nested more than 1 layer deep fail terraform get (and also ${path.module} makes no sense) #1232

Closed
bitglue opened this issue Mar 18, 2015 · 4 comments · Fixed by #1314
Assignees

Comments

@bitglue
Copy link

bitglue commented Mar 18, 2015

Say I have a project with three modules, a, b, and c.

a is a module that does nothing.

$ mkdir a b c
$ cd a
$ touch a.tf
$ terraform plan
Refreshing Terraform state prior to plan...


No changes. Infrastructure is up-to-date. This means that Terraform
could not detect any differences between your configuration and
the real physical resources that exist. As a result, Terraform
doesn't need to do anything.

So far, so good. Now, b uses a:

$ cd ../b
$ cat > b.tf
module "a" {
    source = "../a"
}
$ terraform get
Get: file:///terraform-test/a
$ terraform plan
Refreshing Terraform state prior to plan...


No changes. Infrastructure is up-to-date. This means that Terraform
could not detect any differences between your configuration and
the real physical resources that exist. As a result, Terraform
doesn't need to do anything.

Awesome carrots. Now c uses b:

$ cd ../c
$ cat > c.tf
module "b" {
    source = "../b"
}
$ terraform get
Get: file:///terraform-test/b
Get: file:///terraform-test/c/.terraform/modules/a
Error loading Terraform: Error downloading modules: error downloading module 'file:///terraform-test/c/.terraform/modules/a': source path error: stat /terraform-test/c/.terraform/modules/a: no such file or directory

💥 💥 💥

Using ${path.module} just makes things even more confusing.

$ cd ../b
$ cat > b.tf
module "a" {
    source = "${path.module}/../a"
}
$ terraform get
Get: file:///terraform-test/b/a
Error loading Terraform: Error downloading modules: error downloading module 'file:///terraform-test/b/a': source path error: stat /terraform-test/b/a: no such file or directory

Did you not see the .. in the path? What if I omit it?

$ cat > b.tf 
module "a" {
    source = "${path.module}/a"
}
$ terraform get
Get: file:///terraform-test/b/${path.module}/a
Error loading Terraform: Error downloading modules: error downloading module 'file:///terraform-test/b/${path.module}/a': source path error: stat /terraform-test/b/${path.module}/a: no such file or directory

Now the variable just isn't expanded at all? 😕 If no .. is worse, how about more ..?

$ cat > b.tf
module "a" {
    source = "${path.module}/../../a"
}
$ terraform get
Get: file:///terraform-test/a

I have no logical explanation for why this works. Does it solve my problem?

$ cd ../c
$ cat > c.tf 
module "b" {
    source = "${path.module}/../../b"
}
$ terraform get
Get: file:///terraform-test/b
Get: file:///terraform-test/c/.terraform/modules/a
Error loading Terraform: Error downloading modules: error downloading module 'file:///terraform-test/c/.terraform/modules/a': source path error: stat /terraform-test/c/.terraform/modules/a: no such file or directory

Apparently not. 😞

@mitchellh
Copy link
Contributor

Interpolations don't work at all in source. We should add validation for that. For the others, I'll take a look here.

@mitchellh mitchellh self-assigned this Mar 25, 2015
@mitchellh
Copy link
Contributor

Found the bug, looking into it further.

@mitchellh
Copy link
Contributor

Fixed in linked PR.

@ghost
Copy link

ghost commented May 3, 2020

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.

@ghost ghost locked and limited conversation to collaborators May 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants