Skip to content
DevOps AI ToolKit
Newsletter
All guides
AI for OpenTofu By James Joyner IV · · 8 min read

OpenTofu Error: 'Missing required argument' — Cause, Fix, and Troubleshooting Guide

Quick answer

Fix OpenTofu 'Error: Missing required argument' by supplying required resource attributes, module inputs, or nested block fields.

  • #opentofu
  • #iac
  • #troubleshooting
  • #errors
Free toolkit

Fixing errors like this? Get 500 free DevOps AI prompts

500 copy-paste AI prompts for the stack you actually run — one PDF, free.

Overview

Provider schemas and module interfaces mark some arguments as required. If you omit one — a mandatory resource attribute, a nested-block field, or a module variable with no default — OpenTofu refuses to proceed and names exactly what is missing:

Error: Missing required argument

  on main.tf line 8, in resource "aws_instance" "web":
   8: resource "aws_instance" "web" {

The argument "instance_type" is required, but no definition was found.

Symptoms

  • tofu validate/plan fails with Missing required argument.
  • The message names the required argument and the block it belongs to.
  • Common with new resources copied from partial examples, or module calls missing an input.
  • Nested-block variants say the argument is required “in a X block.”

Common Root Causes

  • Omitted required attribute — e.g., instance_type, bucket, name.
  • Module input without a default not passed by the caller.
  • Missing nested-block field — a required key inside ebs, setting, filter, etc.
  • Conditional set to null — a ternary produced null for a required argument.
  • Removed line during a refactor that dropped a required field.

How to diagnose

OpenTofu names the argument and location — go there first:

tofu validate

Confirm which arguments a resource requires via the schema:

tofu providers schema -json \
  | jq '.provider_schemas["registry.opentofu.org/hashicorp/aws"].resource_schemas["aws_instance"].block.attributes
        | to_entries | map(select(.value.required==true)) | map(.key)'

For a module call, list its required variables (those without a default):

grep -rnA4 'variable ' modules/network/ | grep -B3 -L 'default'

Fixes

Supply the required attribute:

resource "aws_instance" "web" {
  ami           = var.ami_id
  instance_type = "t3.micro"   # was missing
}

Pass the missing module input:

module "network" {
  source     = "./modules/network"
  cidr_block = "10.0.0.0/16"   # required variable, no default
}

Avoid null for a required argument — provide a real fallback:

instance_type = var.size != null ? var.size : "t3.micro"

Re-validate:

tofu validate && tofu plan

What to watch out for

  • null counts as “not set” for required arguments — a ternary must yield a concrete value.
  • The provider schema is authoritative about what is required; grep it rather than guessing from examples.
  • Give module variables sensible defaults where appropriate so callers are not forced to set everything.
  • Run tofu validate in CI to catch missing arguments before any API calls.
Free download · 368-page PDF

Get 500 Battle-Tested DevOps AI Prompts — Free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.