Terraform Deprecated Syntax Checker

Find the syntax that changed in 0.12, 0.13 and since. Some of it still works and will not forever; some of it a current Terraform refuses outright, with an error that does not mention the rename.

Paste below, or drop a file anywhere on this panel

Or drop a file anywhere on this panel. Nothing is uploaded: the analysis runs in this tab.

The answer appears here

Paste on the left and press Check. Nothing leaves this tab.

Examples

Real input you can load into the tool above. Each one shows a different thing going wrong, because that is what the tool is for.

A quoted type name

Correct in 0.11 and an error since 0.12

variable "region" {
  type = "string"
}

The template_file data source

The provider has no Apple Silicon build, so init fails on a recent Mac

data "template_file" "init" {
  template = file("init.sh")
}

An interpolation-only string

Still works, and converts the result to a string on the way through

bucket = "${var.bucket_name}"

Common mistakes

These are the ones that fail silently. The config is accepted, nothing raises an error, and the consequence arrives later.

  1. Treating an unknown function error as a provider problem

    list() and map() were removed in 0.12, and the error names an unknown function. People go looking for a provider that supplies it.

    Instead:Use the literal syntax: ["a", "b"] and { a = "b" }.

  2. Wrapping every expression in quotes and ${ }

    It works and it converts the result to a string, so a number or a list becomes text and the type error appears far from the cause.

    Instead:Write the expression bare: region = var.region.

  3. Keeping template_file because it still works

    The template provider has no darwin_arm64 build, so the configuration cannot init at all on a recent Mac. The failure arrives with a new laptop, not with a change to the code.

    Instead:Use the built-in templatefile(path, vars) function. No provider needed.

The errors for old syntax rarely mention what replaced it

That is what makes this category expensive: the message describes the symptom accurately and says nothing about the version the syntax came from.

A quoted primitive type is an error now

type = "string" was correct in 0.11. From 0.12 the type is a keyword, and the quoted form has been rejected for several majors. It survives in modules nobody has needed to touch, and the fix is to remove the quotes and, for a collection, say what it holds: list(string).

list() and map() were removed in 0.12

They are still all over copied snippets. The error names an unknown function, which reads like a missing provider rather than a removed builtin. The literal forms are ["a", "b"] and { a = "b" }.

An interpolation-only string converts its result

region = "${var.region}" still works, and it turns whatever the expression produced into a string. A number or a list silently becomes text and the type error appears somewhere else entirely. Write the expression bare.

template_file cannot init on Apple Silicon

The template provider is deprecated and has no darwin_arm64 build, so a configuration using it fails at init on any recent Mac. That is usually how a team discovers the deprecation. The built-in templatefile(path, vars) function needs no provider at all.

version inside a provider block is ignored when required_providers exists

Deprecated since 0.13, and still accepted. When both are present the required_providers entry wins, so the line you are reading is not necessarily the one in force, and the two can disagree indefinitely.

null_resource has a built-in replacement

terraform_data arrived in 1.4 and does the same job with no provider to download, lock or hash. null_resource still works; it is one more thing in your lock file for no benefit.

More terraform tools

Terraform Validator & Formatter Does it parse, and is it formatted? Terraform dynamic Block Generator It is ingress.value, not each.value Terraform check and precondition Generator A failed check does not stop the apply Terraform variables.tf Generator From the var. references you already wrote Terraform Unused Declaration Linter Dead variables, locals and data sources Terraform Atlantis YAML Generator when_modified misses your modules Terraform Function Tester and HCL Console terraform console, in a tab Terraform for Expression Tester Where do the keys collide? Terraform Interpolation Tester null becomes an empty string Terraform templatefile Tester Render it before you apply it Terraform Resource Count Calculator How many objects, not how many blocks Terraform count to for_each Converter With the moved blocks it needs Terraform moved Block Generator Rename without destroying Terraform state mv Command Builder No plan, no undo Terraform target Flag Builder And why to stop using it Terraform outputs.tf Generator Outputs are not sensitive by default Terraform Remote State Data Source Generator It grants read of the whole state Terraform Provider Block Generator docker is not hashicorp/docker Terraform .gitignore Generator and Checker .terraform* eats the lock file Terraform to OpenTofu Migration Checker The state is the part to watch Terraform tfvars to JSON Converter The JSON file wins Terraform Version Constraint Parser What ~> actually allows Terraform Resource Address Parser Quote it before the shell eats it Terraform cidrsubnet Calculator newbits is added, not the target Terraform Import Block Generator The id is not the name Terraform Lock File Viewer Why CI fails and your laptop does not Terraform Variables Checker A missing value hangs CI Terraform tfvars to Env Vars Converter Lists and maps have to be JSON Terraform State File Viewer Read it without uploading it Terraform Plan JSON Viewer It is not redacted Terraform HCL to JSON Converter And what the conversion loses Terraform Module Source Validator version only works for the registry Terraform Backend Config Decoder Is state actually locked? Terraform Naming Convention Validator A hyphen makes a resource unreferenceable

Elsewhere on the site