-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Issue with depending on resource from different module #16983
Comments
How does it behave if you remove the depends on? |
@ColinHebert My problem is that the resource that depends on the other resource might not have anything to do with the first one. Not sure why it isn't possible to depend on output, seem very logical and easy to graph such thing.. |
Not necessarily in this case, depending on a specific output is very similar to depending on an attribute of a resource. What is usually done in Terraform is depending on the resource itself (not its attribute), and that is done more often than not implicitly by terraform). So if you wanted to absolutely have a But as I said, this is expected to be handled by terraform, the fact that your |
@ColinHebert That is actually a mistake. That CSE resource isn't running on the same VM. |
It seems I was wrong:
Source: https://www.terraform.io/docs/modules/usage.html So in that case I would go with a |
Great discussion here @pixelicous and @ColinHebert! Thanks. As you saw in the docs, modules are implemented in a special way compared to resources where the dependencies are on individual variables and outputs rather than the module as a whole. As noted in that text, this allows Terraform to maximize parallelism by getting started on parts of a module where possible, rather than waiting until the entire thing is complete before proceeding. However, it is true that Interestingly based on the error here it seems like Terraform is already attempting to support this, probably by coincidence due to how the dependency graph is built. The fact that it split We already have #10462 open about the idea of supporting The Terraform team at HashiCorp is currently focused on some more general configuration language improvements, but we'll think some more about this and see how well it works once we're ready to start looking at explicit dependencies between modules. Thanks for the suggestion! |
@apparentlymart Hi, well if we are speaking on maximuizing parallelism then you should support depending on services that are inside a module. Terraform is actually doing this right now, i have two modules, one which is nested. the nested module is creating nics with dynamic ip addresses and outputs the ip and i have a parent module that is setting the same nics with static ip and it utilizes the output ip address from the nested module, so basically it depends on that ip address.. its just not explicit depending on it, the graph does it, it understand it needs that IP address before it can set it as static ip.. so something of this nature can be supported if needed.. |
Hi all! Support for module outputs and variables inside I verified this on the v0.12.0-alpha1 prerelease build using the following root module: module "child" {
source = "./child"
}
resource "null_resource" "bar" {
depends_on = [module.child.foo]
} The child module contains the following: resource "null_resource" "foo" {
}
output "foo" {
value = null_resource.foo.id
} Including The top-level I then updated the root module to the following: module "child" {
source = "./child"
}
module "child2" {
source = "./child2"
foo_id = module.child.foo
} This introduces the "child2" module, which has the following configuration: variable "foo_id" {
}
resource "null_resource" "baz" {
depends_on = [var.foo_id]
} Now This completes the support for output values and input variables in Since the feature of using |
@apparentlymart Is there a way to create a proper dependency relation if I have no direct access to the child module resources ? Let's say I want to use an external module (https://github.com/hashicorp/terraform-aws-vault/blob/master/modules/private-tls-cert), which only outputs variables. The module generate a certificate file and i'm trying to render the file content, but my file() function is run before the module has finish creating the file. How can I make sure my own resource is triggered after the whole module has finish running ?
Thanks for your time :) Edited: Oh well I think I found more informations on my use case here : #22036 |
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. |
I have a module that calls another module named infrastructure.
The parent module has a azurerm_virtual_machine_extension resource and the child module has a virtual machine resource i am trying to "depend on".
For some reason i cannot make this work, it throws out a message it cant find the module but it seems to me it cant find the resource itself.
Terraform Version
0.11.1
Terraform Configuration Files
Calling the module:
The resource which calls the dependancy:
The resource that is created under child "infrastructure" module
output "vm" {
value = "${azurerm_virtual_machine.vm.id}"
}
Debug Output
from log, only find i could find related to those objects.
[DEBUG] ReferenceTransformer: "module.TenantOnBoard.module.Infrastructure.output.vm" references: [module.TenantOnBoard.module.Infrastructure.azurerm_virtual_machine.vm]
Crash Output
azurerm_virtual_machine_extension.vm_cse: resource depends on non-existent module 'Infrastructure.vm'
Expected Behavior
CSE extension from parent root could depend on output of VM once it is ready
Actual Behavior
Fails with above error
Steps to Reproduce
Terraform apply
Important Factoids
I have added ".id" to the return object of the virtual machine resource, that didn't help.
This isn't the only resource that I had this issue with, I also tried doing this the other way around, depend on a virtual_macihne_extension resource while i have on the parent module a virtual machine that is depending on it
The text was updated successfully, but these errors were encountered: