我有一个如下的数据结构:
locals {
replication_tasks = {
track_to_s3_live = {
replication_task_id = "track-to-s3"
migration_type = "full-load-and-cdc"
replication_task_settings = file("files/s3_tracking_cdc_settings.json")
table_mappings = file("files/s3_tracking_table_mappings.json")
source_endpoint_key = "source"
target_endpoint_key = "s3_tracking"
}
}
}
由此,我尝试编写等效的 .tfvars 文件(用于另一个模块)。类似于:
resource "local_file" "file" {
content = <<EOF
replication_tasks = "${local.replication_tasks}"
EOF
filename = "${path.module}/tasks.auto.tfvars"
}
但是我收到此错误:
Cannot include the given value in a string template: string required.
关于如何实现这一点有什么建议吗?
不确定你为什么要这样做,但是为了生成所需的文件,你只需序列化本地值: