-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Allow data resource that lookup sets of items to return empty sets. #17540
Comments
Glad to see that. It looks like other more specific issues predate this one. I'll leave it up to you to decide if having a totally general issues open is worth while. If not I'm find with this being marked as a duplicate. Keep up the good work! p.s. could someone please acknowledge hashicorp/terraform#13022 ? |
We have now documented in our Provider Design documentation that plural data sources should return zero, one, or multiple results without error. Singular data sources should still return an error when the remote component is not found. We can go back through any non-conformant plural data sources to fix them up, but this might want to wait until our next major release since it is a behavior change for the existing cases. I'm going to mark it with that milestone for tracking for now, but it might be done sooner depending on some further investigation work to determine if it was previously possible to rely on the error in configurations (e.g. with
The maintainers for this project are separate. We cannot influence any prioritization efforts upstream. The product manager for Terraform CLI is fairly open to meeting with folks to discuss things, so that is a potential option there. |
I was wondering if there are any updates on this or #13951 ? |
List of Affected Data Sources:
|
This functionality has been released in v4.0.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
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. |
Community Note
Description
data resource that exist to generate a list of items should (or should be able to) return an empty list when no resource match the filters used.
New or Affected Resource(s)
More or less any data resource ending in a plural, a few of many that likely exhibit this issue:
aws_autoscaling_groups
aws_instances
aws_subnet_ids
Potential Terraform Configuration
I need to create a resource for_each of some other thing. Things that exists outside TF's control.
(note this is only one of several patterns that run into this problem, but in my experience the most common.)
Right now this works, but only when something is actually found.
When the possibility exist that in, non error condition, there may be zero of those things, making things work is much more complex.
All (or most) data resource that lookup sets of things issue an error when they find nothing.
Attempted Solutions
The general workaround is to use a wider query that is assured to always return something and lookup enough about each of those results to manually filter that in terraform.
Besides being much more complex and requiring many more data requests, this has many other issues that I shouldn't need to go into.
References
hashicorp/terraform#27712
The text was updated successfully, but these errors were encountered: