Skip to main content
DevOps Insightsguides & answers

Terraform · troubleshooting

Error: Missing required argument

A resource, data source or module block leaves out an argument that it must have. Usually it was never set, it is misspelt (look for an Unsupported argument error beside it), or a module variable without a default was not passed.

Reproduced on Terraform 1.14.0, . Where the text says “reproduced”, the behaviour was run on that version, not taken from documentation.

First published

New to this? Read what is actually happening first, then come back to the steps.

On this page · 8 sections

Before you start

  • terraform init run, so the provider and module schemas are installed.

Run this first

step 1 of 1
terraform validate

Look for Missing required argument and Unsupported argument for the same block

Lists every missing and unexpected argument at once, without calling any API.

Work out which cause you have

A few questions to narrow the list. Every answer ends in a command that confirms or rules the cause out — this cannot see your cluster, so nothing here is a certainty until you have checked.

Narrow it down

0 answered · nothing is sent anywhere

Is there also an Unsupported argument error for the same block?

Cause space

4 of 4 still possible

  • The argument was never setCommon
  • It is set, but misspeltCommon
  • A module input without a default was not passedCommon
  • A provider upgrade changed what is requiredOccasional

Nothing ruled out yet. Answer the question above and the branches your answer eliminates will strike through here.

Or diagnose it manually

In this order. The first command usually contains the whole answer.

  1. Step 1

    terraform validate

    Lists every missing and unexpected argument at once, without calling any API.

    Look for Missing required argument and Unsupported argument for the same block

Every cause, and how to fix it

Ordered by how often each one turns out to be the answer.

The argument was never set

Common

Copied from an example that set it elsewhere, or left out on purpose expecting a default that does not exist.

Confirm

terraform validate

The argument named in the message

Fix

  • Set it. The resource's page in the provider documentation lists required arguments first.

It is set, but misspelt

Common

Terraform does not see the misspelt argument as the required one, so it reports one missing and one unexpected.

Confirm

terraform validate

Unsupported argument with Did you mean for the same block

Fix

  • Correct the spelling.

A module input without a default was not passed

Common

Every variable block in a module that has no default must be set in the module block that calls it. A new module version can add one.

Confirm

grep -n -A3 'variable "NAME"' path/to/module/*.tf

Open the file at the line grep prints and read the whole variable block: no default = line inside it

Fix

  • Pass it in the module block, or give the variable a default in the module if it should be optional.

A provider upgrade changed what is required

Occasional

Major provider releases sometimes make an argument required or move settings to a separate resource. Not reproduced here.

Confirm

terraform version

The provider version, compared with the upgrade guide for that major version

Fix

  • Follow the provider's upgrade guide, or pin the previous version in required_providers while you migrate.

Understanding it properly

Skip this if you are mid-incident — the working part of the page is above. Worth reading afterwards, because understanding the mechanism is what stops the next one.

In plain terms

Some arguments have no sensible default, so Terraform insists you set them: a bucket name, an AMI (Amazon Machine Image), a module's required inputs. When one is missing, Terraform names it and stops before planning.

Words used on this page

Required argument
An argument the provider's schema marks as required, or a module variable with no default.
Module input
A variable block in the module; one without a default becomes a required argument of the module block.
What is actually happening

Reproduced on Terraform 1.14.0: a terraform_remote_state data block without backend printed Error: Missing required argument and The argument "backend" is required, but no definition was found.

Misspelt as backnd, the same block printed both that error and Unsupported argument with Did you mean "backend"?. When both appear, fix the spelling and both go.

A module block that left out a variable with no default printed the same error, naming the variable. A variable with a default was not required.

A provider upgrade can make an argument required, or move it, so a configuration that validated before fails after terraform init -upgrade. That follows from how validation works; it was not reproduced here, because no real provider was downloaded.

How to tell this is your problem
WhereWhat you see
terraform validate, plan or applyError: Missing required argument ... The argument "NAME" is required, but no definition was found.
Often beside itError: Unsupported argument ... Did you mean "NAME"?

How to know it is actually fixed

  • terraform validate prints Success! The configuration is valid.

Stopping it happening again

  • Pin provider and module versions, and run terraform validate in CI before any plan.

Sources

Behaviour described here is drawn from official documentation. Where a figure could not be confirmed on an official page it is attributed in the text rather than stated as canonical.

Did this get you to an answer?

No text box on purpose — please do not paste production logs anywhere

Something wrong or out of date? Report it