The "Unsupported argument in child module call" error occurs when you pass an argument to a module that doesn't correspond to any input variable defined in that module. Fix this by verifying variable names match between the module call and the child module's variable definitions.
The "Unsupported argument in child module call" error means Terraform found an argument in your module block that doesn't match any input variable declared in the child module. Terraform module arguments must correspond exactly to variables defined in the module you're calling. This error indicates a configuration mismatch where: - You're passing an argument name that doesn't exist as a variable in the child module - There's a typo in the argument name - The child module was updated and a variable was removed or renamed - You're using the wrong module source (calling a different module than intended) - The variable name uses different naming conventions (snake_case vs camelCase)
Read the error message carefully. It will tell you exactly which argument is unsupported:
Error: Unsupported argument
on main.tf line 5, in module "example":
5: invalid_arg = "some_value"
An argument named "invalid_arg" is not expected here.Note the line number and the exact argument name that's causing the error. This is the starting point for your fix.
Navigate to the child module directory and examine its variable definitions:
cat ./modules/example/variables.tfLook for all variable blocks and write down the exact variable names:
# In ./modules/example/variables.tf
variable "instance_type" {
type = string
}
variable "environment" {
type = string
}These are the ONLY argument names you can pass to this module. Any other names will cause the error.
Open your module call in the parent configuration and compare each argument with the variables list:
# WRONG - uses argument name not defined in child module
module "example" {
source = "./modules/example"
instance_type = "t2.micro" # OK - variable exists
invalid_arg = "value" # WRONG - not in variables.tf
}
# CORRECT - all arguments match variable names
module "example" {
source = "./modules/example"
instance_type = "t2.micro"
environment = "prod"
}Remove or rename any arguments that don't appear as variables in the child module.
Common mistakes include:
- Off-by-one character differences: instace_type vs instance_type
- Wrong casing: InstanceType vs instance_type
- Wrong separators: instance-type vs instance_type
- Extra underscores: instance__type vs instance_type
Use a text editor's find-and-replace feature to ensure consistency. Search for the variable name in both files:
# Find all occurrences in parent module
grep -n "instance_type" main.tf
# Find all occurrences in child module
grep -n "instance_type" modules/example/variables.tfCompare the exact strings character-by-character.
Confirm you're calling the intended module:
module "example" {
# Make sure this points to the RIGHT module
source = "./modules/example"
# If using registry modules, check the module page
# source = "terraform-aws-modules/vpc/aws"
}If using a Terraform Registry module, visit the module's documentation page to find the correct variable names:
# Example for AWS VPC module
# https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/latestRegistry modules may have different variable names than your local modules. Always check the documentation.
After correcting the argument names, validate your configuration:
terraform validateIf validation passes, you can safely run plan and apply:
terraform plan
terraform applyIf you still see the error, double-check your variable names are spelled exactly as they appear in the child module's variables.tf file.
Module Inheritance and Argument Forwarding: Child modules can only accept arguments that are explicitly defined as variables. There is no automatic inheritance or forwarding of arguments from parent modules. This is intentional—it enforces explicit contracts between modules.
Provider Arguments Are Different: Arguments for configuring providers (like provider, alias, for_each, count, depends_on) are NOT the same as input variables. These are meta-arguments handled by Terraform itself. Only use these on the module block directly, not as variable names in the child module.
Local vs Registry Modules: Local modules (using source = "./path") and registry modules (source = "namespace/name/provider") may have different variable names. Always check the exact documentation for the module you're using.
Module Versioning: When using registry modules with version constraints, be aware that major version upgrades may change variable names. If you add a version constraint and get this error, check the module's changelog for renamed or removed variables.
Debugging with terraform console: For complex modules, use terraform console to test variable combinations:
terraform console
module.example.var.instance_typeThis shows you what variables the module accepts.
Using Locals to Bridge Argument Names: If you have many modules using different variable naming conventions, you can use local values to map between them:
locals {
# Map your standard names to module-specific names
instance_config = {
instance_type = var.vm_size
environment = var.env_name
}
}
module "example" {
source = "./modules/example"
instance_type = local.instance_config.instance_type
environment = local.instance_config.environment
}Error: Error installing helm release: cannot re-use a name that is still in use
How to fix "release name in use" error in Terraform with Helm
Error: Error creating GKE Cluster: BadRequest
BadRequest error creating GKE cluster in Terraform
Error: External program failed to produce valid JSON
External program failed to produce valid JSON
Error: network is unreachable
How to fix "network is unreachable" in Terraform
Error: Error rendering template: template not found
How to fix "template not found" error in Terraform