Your query returned no results (data source) Terraform Origin: Platform & cloud OSI layer 7 · Application Last updated 5 Nov 2026

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.

Exact message you may see 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
Seen on: Terraform AWS

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

  1. Test the same filter with the CLI (aws ec2 describe-images --filters ...)
  2. Set correct owners/region
  3. Use depends_on or remove the data source for objects created in the same run

Detailed fix by platform

AWS

  1. aws ec2 describe-images --owners amazon --filters "Name=name,Values=al2023-ami-2023*" --query 'Images[].Name'

How to diagnose

  1. Filters — Match?
  2. Region — Right?
  3. 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:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

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 (Terraform)Invalid count argumen…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 (Terraform)Invalid for_each argu…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 (Terraform)Invalid index: The gi…InvalidAMIID.NotFound — InvalidAMIID.NotFound: The image id '[ami-xxxx]' does not exist (AWS)InvalidAMIID.NotFoundProvider produced invalid plan / inconsistent final plan — Terraform: Error: Provider produced invalid plan — provider produced an invalid plan for aws_x.y, but we are tolerating it because it is using the legacy plugin SDK (Terraform)Provider produced inv…Reference to undeclared resource — Terraform: Error: Reference to undeclared resource / Reference to undeclared input variable (Terraform)Reference to undeclar…Saved plan is stale — Terraform: Error: Saved plan is stale — The given plan file can no longer be applied because the state was changed by another operation after the plan was created (Terraform)Saved plan is staleYour quer…

Explore the map of this error Full error map →

🧠 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.