Skip to content

deprecated-index

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

Reports a list item read with the legacy dot syntax, a.0. The fix writes a[0].

The dot form is a deprecated spelling of the index. Newer versions of the language reject it or treat it differently, and the bracket form works with every expression.

Reported
...
raw = "${~ var.f ~}"
id2 = aws_instance.web.0.id
all = aws_instance.web[0].id
ids = aws_instance.web.*.id
num = local.versions.1.2
...
}
After the fix
...
raw = "${~ var.f ~}"
id2 = aws_instance.web[0].id
all = aws_instance.web[0].id
ids = aws_instance.web.*.id
num = local.versions[1][2]
...
}
hcl:
lint:
rules:
deprecated-index: warn # off, warn (default), error

Enabled by the presets: hcl/tflint-recommended.

Suppress one line with sudsy-disable-next-line deprecated-index 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_index full