Terraform "Missing required argument" for a module variable in CI
A module declares an input variable with no default, so it is required. The module block that calls it does not pass a value for that argument, and Terraform refuses to plan until it is supplied.
What this error means
plan or validate stops with "Error: Missing required argument" and "The argument \"X\" is required, but no definition was found." pointing at a module block.
Error: Missing required argument
on main.tf line 5, in module "network":
5: module "network" {
The argument "cidr_block" is required, but no definition was found.Common causes
A required module input was not passed
The module defines variable "cidr_block" {} with no default, so every caller must set it in the module block.
A module upgrade added a new required input
A newer module version introduced a required variable that the existing module block does not yet provide.
How to fix it
Pass the required argument
- Open the module and list variables without a
default. - Set each one in the module block.
- Re-run plan to confirm no required arguments remain.
module "network" {
source = "./modules/network"
cidr_block = "10.0.0.0/16"
}Give the module input a default where appropriate
If a value is optional, add a default to the module's variable so callers are not forced to set it.
variable "cidr_block" {
type = string
default = "10.0.0.0/16"
}How to prevent it
- Set all no-default module inputs in every module block.
- Review module upgrade changelogs for new required inputs.
- Run
terraform validatein CI to catch missing arguments early.