Terraform 需要关于地形列表类型变量的信息吗

Terraform 需要关于地形列表类型变量的信息吗,terraform,terraform-provider-gcp,Terraform,Terraform Provider Gcp,我声明我的列表类型变量如下 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 serv

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

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}"]
  }
错误:属性值类型不正确

在资源中的pure_testing\main.tf第22行 “谷歌计算实例”“默认值”:22:范围= [“${var.service\u account\u scopes}”]

属性“scopes”的值不正确:元素0:字符串 必需的

如果我做错了,你能帮我澄清terraform中列表变量的概念吗


提前感谢。

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


scopes=…
部分中删除方括号,应该可以了。

在删除[]错误后获得如下错误:服务帐户:属性最多支持1项,配置已声明2项。您需要显示完整配置,但该错误听起来像您已声明了
服务帐户
块两次。是,你是对的,我已经申报了2次服务账户,非常感谢你的帮助。我还需要一个帮助(您能帮我理解Terraform中数据的概念吗),再次非常感谢:)