-
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
Depends_on for module #1178
Comments
+1 I came here to ask for this very same thing |
👍 It's not just about adding |
I'm not sure if @felnne covered this as he doesn't have it in his example, but it would also be awesome of modules can depend on other modules
This way, we could bring up infrastructure in the correct order. At the moment, if something like consul depends on say, DNS, we can only have depends within a module itself. This way we can better ensure that services come up in the right order |
+1 agree. Need to have modules that can be re-used atomically with parents connecting the dependency. This modularity enables easier testing, isolation, understandability... all the benefits that code gets from having module packages. For example (with my best text art):
|
+1 |
I just got really excited thinking |
What about the other way around? Having a |
👍 just ran into this - have a module which creates an ASG, and I need it to depend on the user-data template. |
Just wanted to mention that while we don't yet support whole-module dependencies, there's nothing stopping you from wiring an I'm not saying this necessarily will solve all use cases, but when I was trying to figure out why I haven't bumped into the need for |
👍 |
Did anyone find a workaround?
|
Please add this feature, so it gives clear opportunity to use output variables of one module in another one. crash log: https://gist.github.com/youanswer/8ebdcd81aea9edc91f88 |
+1 |
1 similar comment
👍 |
I forgot about modules not supporting |
+1 |
1 similar comment
+1 |
I'd just like to throw out another example of where this would be nice: We have a services module that creates bastions and NATs in a VPC. We lock down port 22 so that only the bastion hosts can be accessed from the internet, but in our bastion module we open port 22 ingress over the entire VPC for connections coming from the bastion hosts. Our NAT module takes as input the bastion host IP (bastion module output) for chef provisioning connections in an Hope that wasn't too rambly. In theory I could probably make the bastion module's output format the CIDR blocks from the |
+1 I've got a situation where one module uploads a number of artifacts to s3, while another module starts up instances that expect the artifacts to exist on s3 and pull them down during boot. As of now, with two discrete modules, there doesn't appear to be a way to tell terraform not to start the instance module until the s3 module has completed its uploads. |
+1 |
@roboll, you might benefit from the |
Yup. Trying to create an IAM Instance Profile for a machine, and then trying to create my aws instance with a custom terraform puppet aws instance module we've created. Can't attach an IAM Instance Profile to it because it |
+1 |
Hello! Im using this scrpit to run plan and apply in the right sequence. #!/bin/bash done |
I solved my problems using I tried to create some The problem was I grouped the So I marked the output "vpc_id" {
depends_on = ["aws_vpc_ipv4_cidr_block_association.secondary_cidrs"]
description = "ID of the VPC"
value = "${aws_vpc.vpc.id}"
} |
This is exactly correct. You can put this value in a tag or some harmless place our you can mess around with it to only make Terraform think it is a dependency:
and now use |
To work around this, I've done the following:
This allows me to use a module in the following manner:
This also makes it possible to specify dependencies on multiple modules. |
+1 we really need this feature |
Seems like this issue should be reopened, since only one half of it is now supported? There's also #10462 (which is still open) but it was created in 2016...is that the right place to watch for updates on this issue? |
+1. Really need this feature, as I already hit the problem a few times. |
+1 |
+1 This feature will be awesome |
Can you please re-open this issue? I think this was closed by accident. Only half of this was implemented. @phinze @mitchellh Everyone +1ing this: Please stop! +1 the issue on top, don't spam with comments. Thanks! |
Yeah we need this. |
We needs this, too. Think of this workflow: Without those dependency you end up e.g. data.kubernetes_service failing with "connection refused" as the EKS does not exist before initial rollout. |
I am defining ECS task definitions and services as a module and would like them to wait on the ECS and/or load balancer (since terraform does not seem to do this on its own). So I would very much like the other half of this to be reopened and completed. |
@charles-salmon Great workaround! Thank you so much for sharing! For my personal use case, I modified the approach a bit to ensure the dependencies are enforced on all Terraform runs and not just the initial one. I changed the
I used the I also changed the
This uses the |
Still can't add depends_on to modules from terraform module registry |
an equals sign after the "triggers" did the trick for me in TF 0.12 |
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. |
Possible workarounds
For module to module dependencies, this workaround by @phinze may help.
Original problem
This issue was promoted by this question on Google Groups.
Terraform version:
Terraform v0.3.7
I have two terraform modules for creating a digital ocean VM and DNS records that are kept purposely modular so they can be reused by others in my organisation.
I want to add a series of provisioners using local_exec after a VM has been created and DNS records made.
Attempted solution
I tried adding a provisioner directly to my terraform file (i.e. not in a resource) which gave an error.
I then tried using the
null_resource
which worked but was executed at the wrong time as it didn't know to wait for the other modules to execute first.I then tried adding a
depends_on
attribute to the null resource using a reference to a module but this doesn't seem to be supported using this syntax:Expected result
Either a way for a resource to depend on a module as a dependency or a way to "inject" (for lack of a better word) some provisioners for a resource into a module without having to make a custom version of that module (I realise that might be a separate issue but it would solve my original problem).
Terraform config used
The text was updated successfully, but these errors were encountered: