Error: Inappropriate value for attribute "cidr_blocks": list of string required
Error: Inappropriate value for attribute "cidr_blocks": list of string required
创建安全组时,我不断收到以下错误
Inappropriate value for attribute "cidr_blocks": list of string
required.
此处摘自 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"
}
]
Inappropriate value for attribute "cidr_blocks": list of string
required.
在 terraform.tfvars
中,您需要将 cidr
从
更改为
cidr = "10.22.9.11/32"
到
cidr = ["10.22.9.11/32"]
创建安全组时,我不断收到以下错误
Inappropriate value for attribute "cidr_blocks": list of string required.
此处摘自 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"
}
]
Inappropriate value for attribute "cidr_blocks": list of string required.
在 terraform.tfvars
中,您需要将 cidr
从
cidr = "10.22.9.11/32"
到
cidr = ["10.22.9.11/32"]