How to fix Error: Missing required argument in Terraform

TerraformBEGINNERMEDIUMUpdated Dec 30, 2025· 136 views

This error occurs when a Terraform resource or module is missing a mandatory argument that the provider or module definition requires. Terraform will tell you exactly which argument is missing and which resource it applies to.

Quick fix

Fixes Error: Missing required argument

Error: Missing required argument

on main.tf line 5, in resource "aws_instance" "example":
  5: resource "aws_instance" "example" {

The argument "ami" is required, but no definition was found.
  1. Read the error message carefully
  2. Check the provider or module documentation
  3. Add the missing argument to your configuration
  4. Verify with terraform validate
terraform — error
Error: Missing required argument
on main.tf line 5, in resource "aws_instance" "example":
5: resource "aws_instance" "example" {
The argument "ami" is required, but no definition was found.
Error: Missing required argument

What this error means

Terraform has detected that a resource block or module call is missing a required argument. Required arguments are inputs that must be provided—they have no default values. This commonly happens when: 1. You're using a resource type and haven't provided all the arguments the provider expects 2. You're calling a module but haven't supplied required input variables 3. You've updated a provider version where previously optional arguments became required 4. You have a typo in the argument name, so Terraform thinks it's missing The error message will specify which argument is missing and the line number where the problem occurs.

Typical symptoms

  • Terraform plan or apply fails immediately with 'Missing required argument' error
  • Error message shows the resource type, argument name, and file location
  • terraform validate reports the missing argument before plan/apply

Common causes

  1. Resource definition is incomplete and lacks a required argument
  2. Module definition is missing a required input variable
  3. Updated provider version has new required arguments
  4. Argument name is misspelled or uses incorrect syntax
  5. Argument is nested inside a required block that wasn't included

How to fix "Error: Missing required argument"

1Read the error message carefully

The error output will tell you:
- The exact argument name that's missing
- The resource or module type
- The file and line number

Example:

bash
Error: Missing required argument

on main.tf line 5, in resource "aws_instance" "example":
  5: resource "aws_instance" "example" {

The argument "ami" is required, but no definition was found.
2Check the provider or module documentation

Look up the resource or module you're using in the official documentation:

1. For built-in resources: Visit the Terraform provider documentation (e.g., terraform.io/docs/providers/aws/r/instance)
2. For modules: Check the module's README or source repository
3. Look at the 'Required' or 'Arguments' section

Note the required arguments and their expected types and formats.

3Add the missing argument to your configuration

Add the missing argument to the resource or module block. Make sure you use the correct argument name and provide a valid value.

Example for a missing ami argument:

hcl
resource "aws_instance" "example" {
  ami           = "ami-12345678"  # Add this
  instance_type = "t2.micro"
}

For module inputs:

hcl
module "vpc" {
  source  = "./modules/vpc"
  cidr    = "10.0.0.0/16"        # Add this
  region  = "us-east-1"
}
4Verify with terraform validate

Run terraform validate to check your configuration syntax and required arguments:

bash
terraform validate

This will catch missing required arguments without applying changes. Fix any errors and re-run validate until it passes.

5Check for provider version changes

If you recently upgraded a provider, some arguments may have become required:

bash
# Check current provider versions
terraform version

# Update to latest provider versions
terraform init -upgrade

After upgrading, run terraform validate again to see if new required arguments are needed.

Advanced notes

Required vs Optional Arguments: In Terraform, arguments are required if they have no default value in the resource definition. Arguments with default values are optional. When you define your own modules, you can control which variables are required by including or omitting default values in the variable block.

For nested blocks (like ingress in security groups), if the block itself is required, you must include at least one instance of it even if all its arguments have defaults.

Use the -json flag with terraform validate for machine-readable error output: terraform validate -json

Frequently asked questions

What does "Error: Missing required argument" mean?
Terraform has detected that a resource block or module call is missing a required argument. Required arguments are inputs that must be provided—they have no default values. This commonly happens when: 1.
How do I fix "Error: Missing required argument"?
This error occurs when a Terraform resource or module is missing a mandatory argument that the provider or module definition requires. Terraform will tell you exactly which argument is missing and which resource it applies to.
What causes "Error: Missing required argument"?
Resource definition is incomplete and lacks a required argument Module definition is missing a required input variable Updated provider version has new required arguments
Is the "Error: Missing required argument" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading