Terraform:如何将地图存储在单个 ssm 参数中并取回值对?
Terraform: How to store a map in a single ssm-parameter and get back a value pair?
假设我有一张这样的地图:
variable "test_parameters" {
type = map
default = {
"A" = "subnet-73e35d3e",
"B" = "subnet-7e00d503",
"C" = "subnet-d9d446b2",
}
}
terraform 代码是什么
- 将地图的值存储在 单个 aws_ssm_parameter ?
- 从参数中获取单个值,例如:B = subnet-7e00d503 或 B:subnet-7e00d503 ?
非常感谢您的帮助 ;)
您可以将其存储为json,然后取回json。
resource "aws_ssm_parameter" "foo" {
name = "myparam"
type = "String"
value = jsonencode(var.test_parameters)
}
阅读:
data "aws_ssm_parameter" "foo" {
name = "myparam"
}
# to use
locals {
myparam_values = jsondecode(data.aws_ssm_parameter.foo.value)
}
假设我有一张这样的地图:
variable "test_parameters" {
type = map
default = {
"A" = "subnet-73e35d3e",
"B" = "subnet-7e00d503",
"C" = "subnet-d9d446b2",
}
}
terraform 代码是什么
- 将地图的值存储在 单个 aws_ssm_parameter ?
- 从参数中获取单个值,例如:B = subnet-7e00d503 或 B:subnet-7e00d503 ?
非常感谢您的帮助 ;)
您可以将其存储为json,然后取回json。
resource "aws_ssm_parameter" "foo" {
name = "myparam"
type = "String"
value = jsonencode(var.test_parameters)
}
阅读:
data "aws_ssm_parameter" "foo" {
name = "myparam"
}
# to use
locals {
myparam_values = jsondecode(data.aws_ssm_parameter.foo.value)
}