-
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 "count" created resources #15285
Comments
Hi @ljsommer, Right now we only support depending on the whole set of instances represented by a single block, like this: depends_on = ["aws_route53_record.squid_server"] This is because internally the In the past there was some design work done to make individual |
Hi @apparentlymart |
One of the cases where it isn't is where you have count set to 0 - for example to disable a particular resource in a module variable. |
Hi @tdmalone, In that case there is still a node in the graph representing the resource, which then becomes a no-op when it is visited, so it should still be valid to specify such a resource in |
Hi all! Sorry for the long silence here. For the original use-case mentioned here, I think the answer for now is to depend on the resource as a whole rather than on a specific instance of it. That has the same effect for Terraform's graph construction anyway, since individual instances do not become separate graph nodes until the apply step. depends_on = ["aws_route53_record.squid_server"] As I noted above, this works even if the resource count is zero, because the dependency is on the resource itself, not any particular instance of it. When I verified this in the v0.12.0-alpha4 prerelease build with the following configuration: variable "instance_count" {
default = 0
}
resource "null_resource" "a" {
count = var.instance_count
}
resource "null_resource" "b" {
depends_on = [null_resource.a]
} For 0.12 we've added explicit support for accepting individual constant instance references in depends_on = [null_resource.a[0]] During planning this still gets processed like Based on what was discussed here, I think the original use-case is addressed, albeit in a different way than suggested, and so I'm going to close this out. If referring to the resource as a whole doesn't address the original problem of creating a dependency between the Route53 record and the ENI, it's likely that there's some other bug here which we can investigate separately. Thanks for opening this feature request, and sorry again for leaving it here unattended for so long. |
@apparentlymart Your solution doesn't appear to be working for me. I have a null resource that depends on a second instance being created, however it is always running even when the second instance doesn't exist? Any ideas?
|
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. |
Use-case:
Request: depends_on to accept either a ${element(aws_route53_record.*.thing, count.index} structure, or at the very least accept resources as they show up in your terraform.state file.
For reference, this is how resources show up in terraform.state that were created with a 'count' operator:
"aws_route53_record.squid_server.0"
I think that depends_on should accept resources that were created in this manner.
This is the error that I am receiving without having the ability to set a dependency in this manner:
"aws_route.private_proxy.0: InvalidParameterValue: Invalid value 'i-0ad9841712b0de0f8' for instance ID. Instance is not in a VPC."
The text was updated successfully, but these errors were encountered: