在terraform中使用工作空间时如何定义列表变量
我有cidr_块,这是列表。如何在列表的变量中定义不同的环境 例如:在terraform中使用工作空间时如何定义列表变量,terraform,Terraform,我有cidr_块,这是列表。如何在列表的变量中定义不同的环境 例如: variable "ingress_cidr_blocks" { type = "list" default = ["0.0.0.0/0"] } variable "ingress_cidr_blocks" { type = &q
variable "ingress_cidr_blocks" {
type = "list"
default = ["0.0.0.0/0"]
}
variable "ingress_cidr_blocks" {
type = "list"
dev = ["0.0.0.0/0"]
}
variable "ingress_cidr_blocks" {
type = "list"
uat = ["0.0.0.0/0"]
}
如何将其转换为
variable "sg_name" {
default = {
default = "tf_sg_default",
dev = "tf_sg_dev",
uat = "tf_sg_uat"
}
}
这是我想要的字符串,列表类型也是一样
如何将其转换为
variable "sg_name" {
default = {
default = "tf_sg_default",
dev = "tf_sg_dev",
uat = "tf_sg_uat"
}
}
不可能。其他对象的默认值:
默认参数需要文字值,不能引用配置中的其他对象
更新:
如何将其转换为
variable "sg_name" {
default = {
default = "tf_sg_default",
dev = "tf_sg_dev",
uat = "tf_sg_uat"
}
}
不可能。其他对象的默认值:
默认参数需要文字值,不能引用配置中的其他对象
更新:
您可以创建
local.sg\u name
值,但不能创建variable
。您可以创建local.sg\u name
值,但不能创建variable
。糟糕的是,在terraform变量“security\u groups\u w”{type=“list”default中使用工作区时,声明列表变量的正确语法是什么={default=[“sg-0fdc9fa416cad5ec3”]dev=[“sg-0fdc9fa416cad5ec3”]uat=[“sg-0fdc9fa416cad5ec3”]}如果你能,我们不能,那么人们在使用workspaces@GirishChandra变量的正确语法在更新的答案中。它不是列表,而是映射。顺便说一句,如果答案有帮助,我们将感谢您接受它。糟糕的是,在terraform中使用工作区时声明列表变量的正确语法是什么变量“security_groups_w”{type=“list”default={default=[“sg-0fdc9fa416cad5ec3”]dev=[“sg-0fdc9fa416cad5ec3”]uat=[“sg-0fdc9fa416cad5ec3”]}如果你能,我们不能,那么人们在使用workspaces@GirishChandra变量的正确语法在更新后的答案中。它不是列表,而是映射。顺便说一句,如果答案有用,请接受。