Terraform Issue — Inappropriate value for attribute “instances”: element 0: string required.

Daniel Bryant
1 min readJun 14, 2019

--

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.

--

--

Daniel Bryant
Daniel Bryant

Written by Daniel Bryant

Platform Engineering @Syntasso | News/Podcasts @InfoQ | Web 1.0/2.0 coder, platform engineer, Java Champion, CS PhD | cloud, K8s, APIs, IPAs | learner/teacher

Responses (1)