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

Module Cannot be Used in depends_on #18239

Closed
dumrauf opened this issue Jun 12, 2018 · 17 comments
Closed

Module Cannot be Used in depends_on #18239

dumrauf opened this issue Jun 12, 2018 · 17 comments

Comments

@dumrauf
Copy link

dumrauf commented Jun 12, 2018

Terraform Version

v0.11.7

Terraform Configuration Files

Note that the below Terraform configuration file leaves out the actual modules some-module and another-module for sake of readability.

module "first-this" {
  source = "modules/some-module"

  ...
}

module "then-that" {
  source = "modules/another-module"

  depends_on = ["module.first-this"]
  ...
}

resource "azurerm_resource_group" "some-rg" {
  name       = "some-name"
  location   = "West US"

  depends_on = ["module.first-this"]
}

Debug/Crash Output

Error: module "then-that": "depends_on" is not a valid argument

Error: azurerm_resource_group.some-rg: resource depends on non-existent resource 'first-this'

Expected Behavior

Ideally, depends_on for modules would work exactly as for resources, i.e., create an explicit dependency between resources/modules and modules.

Actual Behaviour

Terraform exits with above errors

Steps to Reproduce

  1. terraform init

References

A similar report can be found in

@dumrauf dumrauf changed the title depends_on Cannot be Used for Module Module Cannot be Used in depends_on Jun 12, 2018
@jbardin
Copy link
Member

jbardin commented Jun 12, 2018

Hi @dumrauf,

Yes, this is a duplicate of #10462. We'll track the progress of this feature there.

@jbardin jbardin closed this as completed Jun 12, 2018
@gpjonesii
Copy link

gpjonesii commented Jun 13, 2018

@jbardin - #10462 was locked back in March and no updates have been made since. Is this being actively worked on? If the issue is locked, how is the community supposed to build the enhancement?

@jbardin
Copy link
Member

jbardin commented Jun 13, 2018

Hi @gpjonesii,

I understand the concern, but in this case any solution would have to be produced in close concert with the core engineering team so as to not conflict with planned changes. This would happen independently from any single open issue here.

Contrary to what many of the comments suggest, it's not a simple problem, and requires many fundamental changes to be in place before a solution is possible. The foundation for this is in progress, and once that is complete we can proceed with adding this feature. You can read more about the details in issue #17101

@dumrauf
Copy link
Author

dumrauf commented Jun 13, 2018

Hi @jbardin,

I do understand that it takes time to plan and coordinate changes and I am perfectly fine with that.

However, not being able to use depends_on between modules impacts our Terraform modularisation strategy. There are certain workarounds available but they are essentially hacks which I would like to avoid.

Moreover, not being able to upvote issues like this one does not really help surface and prioritise customer problems in my opinion. I do get the point that you don't want to get spammed with '+1's and upvotes but to me that's what makes customer driven product development. You've got a great product - keep it up!

As for the upcoming changes you touched upon - is there an ETA available?

Thanks!

@jbardin
Copy link
Member

jbardin commented Jun 13, 2018

Hi @dumrauf,

While we don't have an ETA, a large portion of the necessary changes will land in the next major release (0.12). The final roadblock will be handled by #17034 (or something similar), but it's not clear yet if that will have to wait for a later release or not.

@Vermyndax
Copy link

Has anyone come up with a viable workaround for this in the meantime?

@dumrauf
Copy link
Author

dumrauf commented Jun 28, 2018

The only viable workaround, which I've found to work, is to

  1. output attributes of relevant resources created in the upstream module and
  2. use the outputs as input variables in the downstream module/resource.

Here, the catch is that you

  1. have to actually use the variables in the downstream module/resource or they will get "optimised" away
  2. need to get the dependencies between resources in the upstream and downstream module/resource right or you may end up with race conditions (this may may also depend on how modules are implemented under the bonnet which I have no insight into)

It's not the best solution in the world but it does the job for now until this issue gets resolved. Please let me know if anyone has a better solution!

@jbardin Any updates in the meantime? Would love to see that feature make it into the next release.

@pstadler
Copy link

pstadler commented Jun 29, 2018

I've been successfully able to work around the missing explicit depends_on functionality between modules until a recent Terraform release. Unfortunately, using output/input variables between modules to ensure the correct behavior is nothing more than a gamble and the whole dependency graph has been completely unreliable since the very beginning.

I really hope this will be solved in the near future.

@dumrauf
Copy link
Author

dumrauf commented Jun 29, 2018

@pstadler, where's it exactly falling apart for you? I'm just wondering as the hackaround is working for us alright so far.

Is the dependency graph any different from what you would expect? Could it be that there are implicit race conditions due to the intrinsic parallel nature of Terraform. This has caught us out once or twice before.

In other news: There may be a glimpse of hope in a recent announcement regarding the upcoming Terraform 0.12 release on https://www.hashicorp.com/blog/terraform-0-1-2-preview. The article mentions depends_on but I couldn't find anything that says this problem would definitely get addressed.

@kim0
Copy link

kim0 commented May 12, 2019

Wondering what's the official status of this in the soon to be released 0.12 ?
Do modules still not support depends_on ?

@Israphel
Copy link

Israphel commented Jun 5, 2019

Still no news about this? I'm using Terraform 0.12.1 and I have the same issues that I had before.

@williamayerst
Copy link

I'm also facing this issue - I have a module which creates a N copies of a complex set of Azure resources, keeping the creation of N resource groups outside of this module.

The first time the job runs, it errors, because the module requires the resource group, and there is no way for me to have this dependency since the resource group variable for the module is interpolated rather than a single data source.

@ikarlashov
Copy link

Common guys, I'm waiting for this feature more than a year. This is a really major feature that needs to be implemented!

@cfullen11
Copy link

Just ran into this issue as well. So adding a vote for feature here

@rgleme
Copy link

rgleme commented Jul 11, 2019

Please, solve it

@awsyadav
Copy link

still open issue , did not got proper resolution

@ghost
Copy link

ghost commented Jul 24, 2019

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 Jul 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests