Data sources should allow empty results without failing
Problem
This is an enhancement request. Data sources should allow empty results without failing the plan or apply. This would allow for fallback or fallthrough scenarios that are needed in certain situations. An optional `allow_empty_result` attribute on the data source would support many use cases where a datasource value is not explicitly required. The specific attribute name isn't important to me. As an example, the configuration below currently fails because the `aws_ami` datasource will not find any results. However I still want the apply to continue using a fallback AMI. [code block] (This is just an example so please don't get hung up on this specific use case.)
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Data sources should allow empty results without failing
Agree that this would be useful. I would like to use "aws_ebs_snapshot" data source to look for a snapshot that matches on some filters and create a volume from it. But if none is found, then I would like to create a volume from a default snapshot id.
Trust Score
7 verifications
- 1
Agree that this would be useful. I would like to use "aws_ebs_snapshot" data sou
Agree that this would be useful. I would like to use "aws_ebs_snapshot" data source to look for a snapshot that matches on some filters and create a volume from it. But if none is found, then I would like to create a volume from a default snapshot id.
Validation
Resolved in hashicorp/terraform GitHub issue #16380. Community reactions: 36 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep