-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
[Feature Request] data "aws_ami" - add "allow_empty" flag #12081
Comments
Just saw this issue and thought I'd add a note, as the original author of the My intention of ensuring that there was one single unique result (or the latest AMI) was to protect against a couple of issues:
I can definitely see why though, in some scenarios, you might not care if the search returned no AMIs (and especially with the advent of more conditional logic in interpolation - a feature that didn't exist in Terraform when I wrote this), but I think it is potentially dangerous to allow zero results to be returned by the data source. Having this gated by a flag, like @joshuaspence did in his PR, is a good idea, but I would propose that we go a step further, forgo the flags in Then, TF config would look like:
This would provide a declaratively semantic way of propagating logic though the graph without having to alter the opinionated nature of the data source. |
The approach suggested by @vancluever seems good to me, and consistent with how we addressed a similar use-case for subnets recently. I would suggest calling the data source |
Thanks for the feedback, I've updated my pull request accordingly. |
Fixes #12081. Adds new `aws_ami_ids` and `aws_ebs_snapshot_ids` resources.
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. |
Currently I must match at least one result if I use the "aws_ami" data source.
I would like to implement an A/B lookup of AMI values using the aws_ami data source.
For example, AMI set "A" includes testing AMIs that match a particular environment,
and AMI set "B" includes production AMIs that match all environments.
I would like to be able to select from
coalesce(A, B)
, but to do this today means I must structure my image tags for both AMI lookups to return one result each, and dynamically decideA != "known-default" ? A : B
Actual Behavior
Null set results in a terraform error and
plan
phase halts.Desired Behavior
Null set results in a terraform error only if requested flag
allow_empty
is false.The text was updated successfully, but these errors were encountered: