OpenTofu Error: 'Missing required argument' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Missing required argument' by supplying required resource attributes, module inputs, or nested block fields.
- #opentofu
- #iac
- #troubleshooting
- #errors
Stuck on this OpenTofu error? Get the free incident triage checklist
A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.
What this error means
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.
When it appears
tofu validate/planfails withMissing 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.”
Configuration 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
nullfor a required argument. - Removed line during a refactor that dropped a required field.
Validating the configuration
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'
Resolution
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
Keeping definitions valid
nullcounts 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 validatein CI to catch missing arguments before any API calls.
Related configuration errors
- OpenTofu Error: ‘Unsupported argument’ — Cause, Fix, and Troubleshooting Guide
- OpenTofu Error: ‘Invalid function argument’ — Cause, Fix, and Troubleshooting Guide
- OpenTofu Error: ‘Unsuitable value type’ — Cause, Fix, and Troubleshooting Guide
Fixed it? Get 500 OpenTofu & 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.
Did this fix your issue?
Trending errors this week
The error guides other engineers are actually reading right now.
- 1mount: wrong fs type, bad option, bad superblock
- 2Docker 'failed to set up container networking': Fix the Bridge and IP Pool
- 3Docker 'failed to create shim task': How to Fix the containerd Runtime Error
- 4modprobe: FATAL: Module not found
- 5mount: wrong fs type, bad option, bad superblock
- 6Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
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.