【发布时间】:2021-07-17 20:56:05
【问题描述】:
我刚刚从 Terraform v0.11.11 更新到 v0.12.1,我现在看到了这些问题。我将整个列表放在一个列表中,但我已经尝试了各种方法来解决这个问题,但没有运气。我在 cidr_blocks = [ 之后删除了 LBracket,但没有成功我尝试在 ${} 中进行变形,不行.我尝试在 var.cidr_groups 之后删除 lbrackets.. 就像没有运气 var.cidr_groups"mainoffice"。我哪里错了?
resource "aws_security_group" "common_access" {
name = "common_access"
description = "common_access"
vpc_id = "${aws_vpc.myvcp.id}"
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [
var.cidr_groups["mainoffice"],
var.cidr_groups["manchester"],
var.cidr_groups["singapore"],
var.cidr_groups["jena"],
var.cidr_groups["fremont"],
var.cidr_groups["indianapolis"],
]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
# TF-UPGRADE-TODO: In Terraform v0.10 and earlier, it was sometimes necessary to
# force an interpolation expression to be interpreted as a list by wrapping it
# in an extra set of list brackets. That form was supported for compatibilty in
# v0.11, but is no longer supported in Terraform v0.12.
#
# If the expression in the following list itself returns a list, remove the
# brackets to avoid interpretation as a list of lists. If the expression
# returns a single list item then leave it as-is and remove this TODO comment.
cidr_blocks = var.cidr_groups["PublicAll"]
}
tags = {
Name = "common_access"
owner = var.contact
terraform = true
}
}
var.cidr_groups 的 Vairables 文件如下所示
variable "cidr_groups" {
default = {
mainoffice = ["10.200.0.0/15"]
manchester = ["10.201.0.0/16"]
singapore = ["10.202.0.0/16"]
jena = ["10.203.0.0/16"]
fremont = ["10.204.0.0/16"]
indianapolis = ["10.205.0.0/16"]
}
}
【问题讨论】:
标签: terraform terraform-provider-aws terraform0.12+