在创建安全组时,我不断收到以下错误消息
属性“ cidr_blocks”的值不合适:字符串列表 必填。
这是 main.tf
的摘录resource "aws_security_group" "sg_sagum" {
name = var.sg_sagum1
vpc_id = data.aws_vpc.vpcname.id
description = var.sg_sagum1
tags = {
Name = var.sg_sagum1
}
dynamic "ingress" {
for_each = [for s in var.sg_sagum_ports : {
from_port = s.from_port
to_port = s.to_port
desc = s.desc
cidrs = s.cidr
}]
content {
from_port = ingress.value.from_port
to_port = ingress.value.to_port
cidr_blocks = ingress.value.cidrs
protocol = "tcp"
description = ingress.value.desc
}
}
}
variables.tf
variable "sg_sagum_ports" {
description = "Ports to be opened on SAGUM SG"
type = list(map(string))
default = []
}
terraform.tfvars
sg_sagum_ports = [
{ from_port = "9000",
to_port = "9000",
cidr = "10.22.9.11/32"
desc = "SAGBPMS"
}
]
属性“ cidr_blocks”的值不合适:字符串列表 必填。
答案 0 :(得分:0)
在terraform.tfvars
中,您需要将cidr
更改为
cidr = "10.22.9.11/32"
到
cidr = ["10.22.9.11/32"]