-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Need improved conditional for creating multiple resources #26811
Comments
You can use |
Hi @Tbohunek, The issues are linked, so we can always refer to both for more detail. You can certainly add more information here if you would like, but it's much easier to track a particular use-case scenario that we may want to solve in one place, rather than various implementation details spread across multiple issues. As for adding an optional Thanks! |
Thanks for clarification @jbardin ! I agree it makes sense in one thread. Why do you see |
|
Point taken. Any other name would have that issue. Can you see anyhow whether certain providers use it or not? Is there any chance you would only add this feature to selected providers such as |
We don't have a comprehensive list of all providers (there are customers with providers which are not publicly available at all), and changing behavior based on the provider type is not an option. The point I was trying to make earlier is that we don't need to discuss the implementation details so much as the use case itself. Until we have a clear case for implementing another way to make resources conditional, the details of how that would work don't matter. Very often as we drill down into the underlying need, a more appropriate solution presents itself. |
@jbardin The use-case is clear. |
Hi @jbardin, I'd like to generate some momentum so here's a use-case. I deploy Landing Zone for 200 Products from my However, when using What do you think of this use-case? |
Coalescing with #21953 right now since that issue has more visibility. |
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. |
Current Terraform Version
Use-cases
As I started to write my Terraform configuration I got to a point where I needed to conditionally create resources. I found the the
count
argument was the way to do this. However, when I attempted to conditionally create resources, Terraform wanted to destroy and create these resources it had already created from an earlier plan. It was pointed out that the address of the resource was different because of the use ofcount
. This means, that any resources created prior to adding the conditional would have to be moved to this new address before theapply
. It seems that thecount
argument was really meant for creating n of resources so it naturally wants to create an array of the resource up to however many there are. But in my use-case, I'm usingcount
with a ternary for true/false evaluation to create the resource or not.Attempted Solutions
Proposal
There should be a way to conditionally create resources without having to use
count
as an argument so that the address of resources do not change, forcing the person to manually move resources to the new address.References
#26809
The text was updated successfully, but these errors were encountered: