Hi there,
0.8.7
terraform modules
I created a module for aws vpc
Am unable to create a depends_on on the module
Terraform doesn't support depends_on in the module
What should have happened?
The depends_oon supports only in resources currently
What actually happened?
if we use that in module it fails saying depends_on not a valid command
If I understand it, you have two modules: module1 and module2 and module2 depend on module1.
To make sure that module2 isn't built first, "import" a value from module1:
module "module1" {
source = "./module1"
}
module "module2" {
source = "./module2"
samevar = "${module.module1.somevar}"
}
Then "export" (i.e., "output") that from module1:
./module1/outputs.tf
output "somevar" {
value = "nothing"
}
and "import" it into module2:
./module2/variables.tf
variable "somevar" {}
Hi Frans
Thanks for your reply, I saw your reply and i can understand that you are asking me to pass the output from module1 as input to module2. If i do this am not sure it will wait for module 1 creation like depends_on works
It should. Because if the export from module1 is a variable in turn, like
output "somevar" {
value = "${some.thing.value}"
}
then module1 needs to be finished first, so that that variable will be known. It _might_ not work if you're exporting a static, but it should if you export a variable..
Try it and see if that helps.
Hi FransUrbo
Thanks for your help in this, I will try this and let you know. Sorry for the late response
Madhu
Should this be closed in favor of #10462?
+1
Indeed @ketzacoatl, this does seem to be the same as what's being discussed in #10462, so I'm going to close this one as a duplicate. Thanks for pointing that out!
If I understand it, you have two modules:
module1andmodule2andmodule2depend onmodule1.To make sure that
module2isn't built first, "import" a value frommodule1:module "module1" { source = "./module1" } module "module2" { source = "./module2" samevar = "${module.module1.somevar}" }Then "export" (i.e., "output") that from module1:
./module1/outputs.tf
output "somevar" { value = "nothing" }and "import" it into module2:
./module2/variables.tf
variable "somevar" {}
In line 7 of the code example is "samevar" supposed to be "somevar"? I tried this solution, but I found resources in module2 that weren't dependent on anything still did not wait for the completion of module1 before starting. Does this workaround actually work?
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
If I understand it, you have two modules:
module1andmodule2andmodule2depend onmodule1.To make sure that
module2isn't built first, "import" a value frommodule1:Then "export" (i.e., "output") that from module1:
./module1/outputs.tf
and "import" it into module2:
./module2/variables.tf