When using functions where arguments are wrapped in double quotes, so there are both outer double quotes around the variable syntax and inner double quotes around the values, json2hcl handles the hcl to json part fine (other than the extra arrays already reported in a different issue), but when converting that json back to hcl the escape characters are not removed.
data "template_file" "iam_instance_policies" {
count = "${length(split(",", var.child["instance_policy_paths"]))}"
template = "${file(join("/", list(path.module, replace(element(split(",", var.child["instance_policy_paths"]), count.index), "\n", ""))))}"
vars {
partition = "${data.aws_partition.current.partition}"
account = "${lookup(var.account_ids, terraform.workspace)}"
}
}
{
"data": [
{
"template_file": [
{
"iam_instance_policies": [
{
"count": "${length(split(\",\", var.child[\"instance_policy_paths\"]))}",
"template": "${file(join(\"/\", list(path.module, replace(element(split(\",\", var.child[\"instance_policy_paths\"]), count.index), \"\\n\", \"\"))))}",
"vars": [
{
"account": "${lookup(var.account_ids, terraform.workspace)}",
"partition": "${data.aws_partition.current.partition}"
}
]
}
]
}
]
}
]
}
"data" = {
"template_file" = {
"iam_instance_policies" = {
"count" = "${length(split(\",\", var.child[\"instance_policy_paths\"]))}"
"template" = "${file(join(\"/\", list(path.module, replace(element(split(\",\", var.child[\"instance_policy_paths\"]), count.index), \"\\n\", \"\"))))}"
"vars" = {
"account" = "${lookup(var.account_ids, terraform.workspace)}"
"partition" = "${data.aws_partition.current.partition}"
}
}
}
}