【发布时间】:2019-06-26 14:32:42
【问题描述】:
在 Terraform 中,我正在尝试构建一个带有 IP 映射和相关评论的 SecurityGroup。 我正在尝试做的是遍历允许网络的映射键值,并关联描述字段的映射值。
代码看起来像这样,
resource "aws_security_group_rule" "ingress" {
type = "ingress"
(...)
cidr_blocks = "${var.ingress_cidr_blocks}"
description = "${var.ingress_description}"
security_group_id = "${aws_security_group.this.id}"
}
module "securitygroup-ssh" {
source = ""
(...)
ingress_from_port = "22"
ingress_cidr_blocks = ["${var.ipLlist}"]
ingress_description = "${var.allowed-network}"
}
以此为变量,
variable "allowed-network" {
type = "map"
default = {
"From Customer1" = "1.1.1.1/32"
"Network this" = "10.0.0.0/24"
}
}
已经在使用 map 和 lookup 内置函数而没有满意的结果。也能够以列表的形式遍历网络,但描述字段似乎被最后一个值覆盖。
有什么想法吗?目前在 Terraform 中这是否可能?
【问题讨论】:
标签: terraform