# Data aws\_ami does not return the latest AMI from marketplace

**URL:** <https://discuss.hashicorp.com/t/data-aws-ami-does-not-return-the-latest-ami-from-marketplace/40466>\
**Category:** Terraform\
**Created:** [June 7, 2022, 5:05am UTC](https://discuss.hashicorp.com/t/data-aws-ami-does-not-return-the-latest-ami-from-marketplace/40466 "2022-06-07T05:05:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![abduljalilk](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/abduljalilk/32/24183_2.png) [@abduljalilk](https://discuss.hashicorp.com/u/abduljalilk)\
**Post date:** [June 7, 2022, 5:05am UTC](https://discuss.hashicorp.com/t/data-aws-ami-does-not-return-the-latest-ami-from-marketplace/40466/1 "2022-06-07T05:05:12Z")

</div>

While using terraform to get the latest AMI ID of the product listed, it is getting the previous version.

product code: azespe814tygw07vf24qp19mi

If we search with the exact name, it is not returning any.  
If we use the describe-mages CLI, we get both AMI listed, but we see a difference

The terraform always returns 8.9 version as the latest, and we can launch

“Name”: “STC-BYOL8.9-b986e134-3bc6-4a23-9ba6-e09db08a07fa”,

Terraform doesn’t list this AMI when filter with this name.

“Name”: “STC-BYOL-8-10-0-b986e134-3bc6-4a23-9ba6-e09db08a07fa”,

data “aws\_ami” “stc-ami” {  
executable\_users = [“self”]  
most\_recent = true  
owners = [“self”, “aws-marketplace”]

filter {  
name = “product-code”  
values = [“azespe814tygw07vf24qp19mi”]  
}  
}
