How to call the data defined in the data source

i have created a image using packer with the tags=packer-terraform now i would like to call the image_id in my terraform file (.tf). provider is openstack version rocky and terrform version 0.12

i would like to use the image id which i would like to get from the data source.

data “openstack_images_image_v2” “centos_packer” {
name = “centos packer image”
most_recent = true

properties = {
tags = “packer-terraform”

output “image_id” {
value =
description = “The image id of the packer image”

i am getting an error “Error: Your query returned no results. Please change your search criteria and try again.”

I use the openstack_images_image_v2 data resource successfully. The error message seems pretty clear but sometimes its hard to track down why. At first glance, I wonder if its the spaces in the name? Something to test would be to remove the “name” and change it to “id” with the matching ID. Then look at the state file to see what TF has listed for the “name” attribute. Its possible it added something to pad for those spaces and the state would show you what it sees. Hope that helps.

I tried with the tags attribute and it worked for me this time. thanks for the attention

1 Like