【发布时间】:2021-09-26 08:34:09
【问题描述】:
我正在使用下面的gcp terraform module 使用terraform 创建gcp firewall 规则
https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_firewall
我需要一些帮助来为防火墙规则中的 allow 参数定义正确的 data type
参数值的一个例子可以如下
fw_dst_tags = "http,https"
fw_allow = [{
protocol = "tcp"
ports = ["80"]
}]
为此我创建了一个变量类型 pf list(object),如下所示
variable "target_tags" {
type = list
}
variable "allow" {
type = list(object({
protocol = string,
ports = list(string,)
}))
}
但它失败并出现以下错误
Error: Unsupported argument
│
│ on ../../modules/fw/fw.tf line 12, in resource "google_compute_firewall" "main":
│ 12: allow = var.allow
│
│ An argument named "allow" is not expected here. Did you mean to define a block of type "allow"?
任何帮助确定以下类型值的正确变量
fw_allow = [{
protocol = "tcp"
ports = ["80"]
}]
【问题讨论】:
-
什么是
fw_allow?它不在链接的文档中。
标签: google-cloud-platform terraform terraform-provider-gcp