-
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
Count referring to count parameter of other resources? #4769
Comments
In the current implementation, the However, another issue in your example that won't be addressed by that proposal is that At present, a top-level variable is the only working approach for what you want to do here. #4149 will partially solve it, but I think further work would be required to make the |
I did notice that; creating an output with a value of count, e.g.
caused the output to disappear entirely – no error message, just no output. I vaguely recall having seen this behavior before when outputs' values can't be interpolated for some reason, but perhaps that's a different issue? In any event, thank you for the prompt and thoughtful response! |
Is a feature like this required in order to, for example, create |
This works now! |
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've looked for an open issue describing this use-case, but while there's a lot of tickets around
count
parameters in general I didn't quite find one that talked to my example. If this is a duplicate of something that exists, I'm sorry!In any event, I have the volition to define a config in the following way:
But currently I see the following error:
Or alternatively, if A has been created ahead of time:
These are null resources to make the example minimal, but I think the use-case applies broadly to "link objects" (like, aws route table associations or ebs attachments). In this example, A might represent some number of resources that B links to a third static position (e.g. a VPC level route table or a single instance). In this case, having a number of link objects that differs from the number of resources would probably be considered an error (more links would wrap around and try to use the same resource twice, and more resources would leave unused capacity).
What I've seen elsewhere is using a variable, i.e. "var.a_count", in both places. While that does work, it feels a bit weighty to require a global variable name to factor out a count from two places to describe the fact that those two resources should vary together. Directly referencing the count meta-parameter would seem, to me, to more clearly demonstrate the relationship.
I've found elsewhere ( #1497 (comment) ) that the general problem of "count interpolation" is complicated due to its inability to refer to computed values. However, as long as this restriction is in effect referencing another resources' count parameter would still be a static pre-configuration value (i.e. like a variable), so it may prove easier to implement than the general computed counts problem.
The text was updated successfully, but these errors were encountered: