Closed asterix201 closed 4 years ago
Hi @asterix201 !
I try reproduce and could not get result as you describe.
$ cat test.tf
// vars definitions
variable "fmg_image_name" {
description = "FortiManager image id"
default = "fedora-31-1582631432"
}
variable "folder_id" {
description = "infra folder id"
default = "standard-images"
}
// data sources
data "yandex_compute_image" "fmg" {
folder_id = var.folder_id
name = var.fmg_image_name
}
// outputs
output "image_id" {
value = data.yandex_compute_image.fmg.id
}
$ YC_TOKEN=$YC_TOKEN terraform apply
data.yandex_compute_image.fmg: Refreshing state...
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
image_id = fd8t9okqs036vlfi4ivi
If I assign intensionaly incorrect folder_id value then get error as you show
$ YC_TOKEN=$YC_TOKEN terraform apply -var folder_id=fsdsdfsdfdsdsfsd
data.yandex_compute_image.fmg: Refreshing state...
Error: failed to resolve data source image by name: image with name "fedora-31-1582631432" not found
on test.tf line 12, in data "yandex_compute_image" "fmg":
12: data "yandex_compute_image" "fmg" {
May be in some place inside tf code default value of variable folder_id
redefined or in wrapper script / command-line arg?
May be in some place inside tf code default value of variable folder_id redefined or in wrapper script / command-line arg?
Reviewed code more closely. Yes, you are right. There was setting another folder_id
in tfvars file and I've missed this.
After update to the correct value, it works.
Thank you a lot for the help! :)
It is not possible to get data about a resource by resource name - I'm getting an error.
But all these resources are exist