Terraform Issue — Inappropriate value for attribute “instances”: element 0: string required.
This is a simple one to fix as part of the Terraform 0.12 upgrade: simply remove the (now unnecessary) brackets from around the interpolated list of of strings e.g.
I started with this:
resource "google_compute_target_pool" "shopfront" {
name = "tf-shopfront-target-pool"
instances = ["${google_compute_instance.vm_shopfront.*.self_link}"]
health_checks = ["${google_compute_http_health_check.shopfront.name}"]
}
After upgrading to Terraform 0.12, and issuing a terraform plan
I saw this
Inappropriate value for attribute "instances": element 0: string required
And the fix was to remove the brackets for the instances
:
resource "google_compute_target_pool" "shopfront" {
name = "tf-shopfront-target-pool"
instances = "${google_compute_instance.vm_shopfront.*.self_link}"
health_checks = ["${google_compute_http_health_check.shopfront.name}"]
}
In general, I’m finding that the error messages in the latest edition of Terraform are superb. I’ve just struggled with a couple of edge cases, typically where I haven’t paid enough attention to the upgrade guide.
Hat tip to the Terraform team for discussing an issue on GitHub related to the problem I was seeing.