/errors/terraform/unsupported-argument
Terraform: Error: Unsupported argument. An argument named "x" is not expected here
- tool
- Terraform
- exit code
- 1
- versions
- Terraform 1.x, OpenTofu 1.x
- os
- any
Terraform checks every block against the schema of its resource type, data source or module. An attribute that the schema does not define stops validate, plan and apply with Error: Unsupported argument and An argument named "x" is not expected here., pointing at the file and line.
Reproduce it
The built-in terraform_data resource has input and triggers_replace, but no name:
cat > main.tf <<'EOF'
resource "terraform_data" "app" {
input = "x"
name = "web"
}
EOF
terraform init -input=false -no-color >/dev/null
terraform validate -no-colorOutput · exit 1
Error: Unsupported argument on main.tf line 3, in resource "terraform_data" "app": 3: name = "web" An argument named "name" is not expected here.
Fix it
-
Open the resource's page in the provider documentation for the version you use (see
.terraform.lock.hcl) and compare the attribute names. -
If the attribute is newer than your provider, raise the constraint and run
terraform init -upgrade:hcl terraform { required_providers { aws = { source = "hashicorp/aws" version = "~> 6.0" } } } -
If the schema defines it as a block, drop the
=:hcl # wrong root_block_device = { volume_size = 20 } # right root_block_device { volume_size = 20 }
For a module, Unsupported argument means the module has no variable with that name: add it to the module's variables.tf, or stop passing it.