Skip to content

deprecated-interpolation

Terraform (HCL)stylefix: safedefault: warnhcl/tflint-recommended

Reports a string that is one interpolation, "${var.a}", where the expression alone does. The fix writes the expression. It is not reported in Nomad job files (.nomad, .nomad.hcl), whose agent fills those in at run time.

Since Terraform 0.12 an expression can stand alone, and wrapping it in a string turns the value into a string, which loses its type (a list or a number becomes text) and adds noise.

Reported
resource "a" "b" {
name = "${var.name}"
tags = ["${var.a}", "x-${var.b}", "${var.c}${var.d}"]
id = "${ var.e }"
raw = "${~ var.f ~}"
...
all = aws_instance.web[0].id
ids = aws_instance.web.*.id
...
key = { "${var.k}" = 1 }
sum = 1 + "${var.n}"
}
After the fix
resource "a" "b" {
name = var.name
tags = [var.a, "x-${var.b}", "${var.c}${var.d}"]
id = var.e
raw = "${~ var.f ~}"
...
all = aws_instance.web[0].id
ids = aws_instance.web.*.id
...
key = { (var.k) = 1 }
sum = 1 + "${var.n}"
}
hcl:
lint:
rules:
deprecated-interpolation:
level: warn # off, warn (default), error
options:
except_in: []
Option Type Default Description
except_in list [] Kinds of the parent (for example Tuple) whose strings are left alone. Tuple: only a string that is a whole argument is reported and unwrapped, as terraform fmt does.

Enabled by the presets: hcl/tflint-recommended.

Suppress one line with sudsy-disable-next-line deprecated-interpolation in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
tflint terraform_deprecated_interpolation full