Reputation: 17040
I have the following variable defined.
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"
},
]
}
Then in my tf module, I want to add an extra item to the list called parameter
.
parameter = "[
"${var.pg_parameters}",
"{
"name": "rds.force_ssl",
"value": "${lookup(var.ssl, element(var.environments, count.index), 1)}",
"apply_method": "pending-reboot"
}",
]"
But instead, I got this error:
Error loading modules: module postgres_ssl_off: Error parsing .terraform/modules/5ee2f0efac9d712d26a43b2388443a7c/main.tf: At 46:17: literal not terminated
I am not sure where the actual termination missing?
Upvotes: 0
Views: 3448
Reputation: 1227
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
}
]
Upvotes: 2