【发布时间】:2021-07-08 13:05:24
【问题描述】:
我基本上是在尝试创建一个规则,以允许来自 ip 地址 x.x.x.x/32(其中 x.x.x.x 是真实 IP 地址)的 ssh、rdp 和 http 流量。
这是我的 tf 文件
resource "aws_security_group" "allow_internet" {
name = "allow_internet"
description = "allow_internet_from_my_connection"
vpc_id = aws_vpc.dee_vpc.id
dynamic "ingress" {
for_each = var.sg_protocols
iterator = protocol
content {
from_port = 0
to_port = 0
protocol = protocol.value
cidr_blocks = ["x.x.x.x/32"]
}
}
这是我的变量
variable "sg_protocols" {
type = list(string)
description = "list of ingress ports"
default = ["rdp", "ssh", "rdp"]
}
我收到以下错误
λ terraform plan
Error: Invalid number literal
on securitygroup.tf line 14, in resource "aws_security_group" "allow_internet":
14: cidr_blocks = [x.x.x.x/32]
Failed to recognize the value of this number literal.
【问题讨论】:
-
修正默认 = ["rdp", "ssh", "http"]
标签: terraform-provider-aws aws-security-group