Aws_ami query fails to find shared AMI

I am stumped as to why the following query fails.

data "aws_ami" "linux_rocky9_arm64" {
  most_recent = true
  owners = ["self", "63XXXXXXXX"]
  executable_users = ["self"]

  filter {
    name   = "name"
    values = ["linux-base-rocky9-arm64"]
  }
}

I am running the plan with an Organizational Unit credentials. I am able to see this shared AMI using AWS CLI aws ec2 describe-images.

terraform plan fails with the following:

╷
│ Error: Your query returned no results. Please change your search criteria and try again.
│
│   with data.aws_ami.linux_rocky9_arm64,
│   on main.tf line 23, in data "aws_ami" "linux_rocky9_arm64":
│   23: data "aws_ami" "linux_rocky9_arm64" {
│
╵

Just to circle back on this and provide the solution…

Ended up being an issue with regions and was caused by my failure to properly set the local environment region vs a global region that was used to create the resources.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.