Terraform: Error: Your query returned no results. Please change your search criteria and try again.
A data source (e.g. aws_ami, aws_vpc) found nothing matching its filters.
Error: Your query returned no results. Please change your search criteria and try again.Your query returned no resultsError: no matching EC2 Image foundError: Invalid data source: no resultsError: reading AMI: empty result Meaning
Fix the filters (name pattern, owners, tags), region/account (provider alias), or create the object first. Verify with the cloud CLI using the same filters. Marketplace/AMI names change; use most_recent = true with correct owners. Data sources run at plan time, so objects created in the same apply may not exist yet.
Common causes
- Wrong filter values/name patterns
- Wrong region/account/provider alias
- AMI/image deprecated or renamed
- Data depends on a resource not created yet
- Missing permissions to list/describe
⚡ Quick fix
- Test the same filter with the CLI (
aws ec2 describe-images --filters ...) - Set correct
owners/region - Use
depends_onor remove the data source for objects created in the same run
Detailed fix by platform
AWS
aws ec2 describe-images --owners amazon --filters "Name=name,Values=al2023-ami-2023*" --query 'Images[].Name'
How to diagnose
- Filters — Match?
- Region — Right?
- Order — Created earlier?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Invalid count argument (value unknown until apply) Terraform: Error: Invalid count argument — The "count" value depends on resource attributes that cannot be determined until apply
- Invalid for_each argument (keys cannot be determined until apply) Terraform: Error: Invalid for_each argument — The "for_each" map includes keys derived from resource attributes that cannot be determined until apply
- Invalid index: The given key does not identify an element Terraform: Error: Invalid index — The given key does not identify an element in this collection value
Most viewed in Terraform
- Error acquiring the state lock Terraform: Error: Error acquiring the state lock — ConditionalCheckFailedException / state blob is already locked
- Inconsistent dependency lock file Terraform: Error: Inconsistent dependency lock file — provider x: required by this configuration but no version is selected
- Resource is tainted and must be replaced Terraform: # aws_instance.web is tainted, so must be replaced — -/+ destroy and then create replacement
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026