-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Labels
bugSomething isn't workingSomething isn't workingfixed-in-8.0this issue has been fixed in `transformer-overhaul` feature branch, to be released as v8.0this issue has been fixed in `transformer-overhaul` feature branch, to be released as v8.0
Description
Describe the bug
When transforming HCL code that includes a templatefile with a map inside, if the values of the map are locals or variables, e.g. local.name or var.name, the transform adds the interpolation literals to the values, so, they end up like "${local.name}" or "${var.name}" and that is a deprecated format. This according to: https://github.com/hashicorp/terraform/releases/tag/v0.12.14
Software:
- OS: macOS
- Python version 3.10.16
- python-hcl2 version (e.g. 7.3.1)
Snippet of HCL2 code causing the unexpected behaviour:
module "my-module" {
source = "my-source"
account_id = local.account_id
region = local.region
service_name = local.service_name
policy = templatefile("./iam_policy.json.tpl", { "name" : local.service_name, "environment" : var.environment, "account_id" : local.account_id, "region" : local.region })
tags = local.tags
}is transformed into:
module "my-module" {
source = "my-source"
account_id = local.account_id
region = local.region
service_name = local.service_name
policy = templatefile("./iam_policy.json.tpl", { "name" : "${local.service_name}", "environment" : "${var.environment}", "account_id" : "${local.account_id}", "region" : "${local.region}" })
tags = local.tags
}Expected behavior
Expected result is to keep the policy = templatefile(... without the interpolation literals:
policy = templatefile("./iam_policy.json.tpl", { "name" : local.service_name, "environment" : var.environment, "account_id" : local.account_id, "region" : local.region })Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixed-in-8.0this issue has been fixed in `transformer-overhaul` feature branch, to be released as v8.0this issue has been fixed in `transformer-overhaul` feature branch, to be released as v8.0