Hi, I'm following the simple module tutorial at http://www.terraform.io/docs/modules/create.html and finding that it doesn't work as described (using current dev compile 0.3.6-dev)
root@eddie:~/terraform/r# ls -al
total 16
drwxr-xr-x 3 root root 4096 Dec 23 14:30 .
drwxr-xr-x 5 root root 4096 Dec 23 14:30 ..
drwxr-xr-x 2 root root 4096 Dec 23 14:31 child
-rw-r--r-- 1 root root 127 Dec 23 14:33 main.tf
root@eddie:~/terraform/r# ls -al child/
total 12
drwxr-xr-x 2 root root 4096 Dec 23 14:31 .
drwxr-xr-x 3 root root 4096 Dec 23 14:30 ..
-rw-r--r-- 1 root root 72 Dec 23 14:31 main.tf
root@eddie:~/terraform/r# cat main.tf
module "child" {
source = "./child"
memory = "1G"
}
output "child_memory" {
value = "${module.child.received}"
}
root@eddie:~/terraform/r# cat child/main.tf
variable "memory" {}
output "received" {
value = "${var.memory}"
}
root@eddie:~/terraform/r# terraform apply
Error downloading modules: module child: not found, may need to be downloaded
A quick look at strace -f terraform apply output _did_ show lstat() for the child directory
[pid 20313] lstat("/root/terraform/r/child", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
.. but no calls for the main.tf inside - what's going on?
Cheers,
Gavin.
Did you run terraform get in advance? In my case, this command created a symlink to the child directory and it could be referred by terraform plan.
Excellent advice, thank you.
root@eddie:~/terraform/r# terraform plan
Error downloading modules: module child: not found, may need to be downloaded
root@eddie:~/terraform/r# terraform get
Get: file:///root/terraform/r/child
root@eddie:~/terraform/r# 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.
root@eddie:~/terraform/r# terraform apply
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
child_memory = 1G
This is then a documentation bug since the only mention of the get command is further down the page in Nested Modules.
Cheers,
Gavin.
Fixed
This hint would be more helpful if it mentioned that local modules need terraform get too. I googled the error and it led me here. I didn't think downloading was what I needed to do for a local file, so I didn't try terraform get.
As an aside, terraform get worked for me but I was surprised by the syntax, minimal as it is. I was expecting to have to tell it what to get. Nope. And my module was all wrong, but terraform get told me what to fix. How cool.
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.
Most helpful comment
This hint would be more helpful if it mentioned that local modules need terraform get too. I googled the error and it led me here. I didn't think downloading was what I needed to do for a local file, so I didn't try terraform get.
As an aside, terraform get worked for me but I was surprised by the syntax, minimal as it is. I was expecting to have to tell it what to get. Nope. And my module was all wrong, but terraform get told me what to fix. How cool.