0
votes

I am declaring my list type variable as below

variable service_account_email {
  description = "The email of the service account for the instance template."
  default     = "default"
}

variable service_account_scopes {
  description = "List of scopes for the instance template service account"
  type        = "list"

  default = [
    "https://www.googleapis.com/auth/compute",
    "https://www.googleapis.com/auth/logging.write",
    "https://www.googleapis.com/auth/monitoring.write",
    "https://www.googleapis.com/auth/devstorage.full_control",
  ]
}

but while trying to use the variable as below getting error as mentioned below :

service_account {
    email  = "${var.service_account_email}"
    scopes = ["${var.service_account_scopes}"]
  }

Error: Incorrect attribute value type

on pure_testing\main.tf line 22, in resource "google_compute_instance" "default": 22: scopes = ["${var.service_account_scopes}"]

Inappropriate value for attribute "scopes": element 0: string required.

If I am doing wrong , could you please help me to clarify the concept of list variables here in terraform.

Thanks in advance.

1

1 Answers

1
votes

You are trying to pass nested lists to the resource.

Remove the square brackets from the scopes = ... part and it should be fine.