terraform
data_error
ai_generated
true
Error: No matching resource found or data source returned no results
ID: terraform/tf-data-source-not-found
85%Fix Rate
87%Confidence
75Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1 | active | — | — | — |
Root Cause
A data source query returned no results because the referenced resource does not exist or filters are too restrictive.
genericWorkarounds
-
88% success Verify the resource exists and the data source filter values are correct
Check the cloud console or CLI that the resource exists in the same region/account, and that filter values match exactly
Sources: https://developer.hashicorp.com/terraform/language/data-sources
-
82% success Create the resource with a Terraform resource block instead of referencing it as a data source
If the resource should be managed by Terraform, convert data block to a resource block
Sources: https://developer.hashicorp.com/terraform/language/data-sources
Dead Ends
Common approaches that don't work:
-
Add a depends_on to make the data source wait
75% fail
If the resource simply does not exist, waiting will not help; depends_on cannot create missing resources
-
Use try() to ignore the missing data source error
80% fail
try() cannot suppress provider-level errors from data sources, only expression evaluation errors
Error Chain
Leads to:
Preceded by: