想要有关 terraform List 类型变量的信息

Want information regarding terraform List type variable

我声明我的列表类型变量如下

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",
  ]
}

但是在尝试使用如下变量时出现如下所述的错误:

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.

如果我做错了,请你帮我澄清一下terraform中列表变量的概念。

提前致谢。

您正在尝试将嵌套列表传递给资源。

去掉scopes = ...部分的方括号就可以了