terraform - Terraform 文字未终止
问题描述
我定义了以下变量。
variable "pg_parameters" {
type = "list"
description = "A list of parameters for configuring the parameter groups."
default = [
{
name = "rds.logical_replication"
value = 1
apply_method = "pending-reboot"
},
]
}
然后在我的 tf 模块中,我想在名为parameter
.
parameter = "[
"${var.pg_parameters}",
"{
"name": "rds.force_ssl",
"value": "${lookup(var.ssl, element(var.environments, count.index), 1)}",
"apply_method": "pending-reboot"
}",
]"
但相反,我收到了这个错误:
Error loading modules: module postgres_ssl_off: Error parsing .terraform/modules/5ee2f0efac9d712d26a43b2388443a7c/main.tf: At 46:17: literal not terminated
我不确定实际终止在哪里丢失?
解决方案
The second element in the list is a map. You need to assign to the map using =
, not :
. You can also drop the "
around the keys, and map itself, like so:
variable "pg_parameters" {
type = "list"
description = "A list of parameters for configuring the parameter groups."
default = [
{
name = "rds.logical_replication"
value = 1
apply_method = "pending-reboot"
},
]
}
locals {
my_params = [
"${var.pg_parameters}",
{
name = "rds.force_ssl"
value = "hello"
apply_method = "pending-reboot"
},
]
}
output "example" {
value = "${local.my_params}"
}
Applying shows
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
example = [
{
apply_method = pending-reboot,
name = rds.logical_replication,
value = 1
},
{
apply_method = pending-reboot,
name = rds.force_ssl,
value = hello
}
]
推荐阅读
- python - 循环问题
- c# - 如何根据 ASP.Net Core 中的某些值显示/隐藏列?
- c# - C#:public Delegates:从不同的类调用
- anaconda - Openpyxl 在保存文件时产生 TypeError,为什么?
- c# - 如何从字符串创建 HTMLElement?
- python - 如何防止 Pyvips 拉伸图像
- v8 - v8::Locker 在 Isolate 中退出当前上下文
- docker - 如何标记图像并将其推送到 GitHub 的注册表?
- python - 如何将标题添加到烧瓶 test_request_context?
- html - 大屏幕上的引导导航栏折叠按钮?