Terraform: Error: Invalid character — This character is not used within the language / Error: Argument or block definition required
The .tf file has HCL syntax errors (stray characters, bad quotes, missing braces/commas).
Error: Invalid characterThis character is not used within the languageError: Argument or block definition requiredAn argument or block definition is required hereError: Invalid expression Expected the start of an expression, but found an invalid expression token Meaning
The error gives file/line/column. Common: curly quotes pasted from docs (“ ”), missing =, JSON-style colons, trailing commas, unclosed braces, using : instead of =, or interpolation syntax errors. Run terraform fmt and terraform validate; editors with HCL plugins highlight issues.
Common causes
- Smart quotes copied from web/docs
- Missing
=or braces - JSON syntax inside HCL
- Unescaped
${in strings ($${) - Wrong block nesting
⚡ Quick fix
- Replace smart quotes with straight quotes
terraform fmt -check -diff && terraform validate- Fix the line/column named
Detailed fix by platform
Terraform
terraform fmt -check -diff && terraform validate
How to diagnose
- Line — File and line?
- Quotes — Straight?
- Syntax — HCL?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Duplicate resource configuration / variable declaration Terraform: Error: Duplicate resource "aws_s3_bucket" configuration — A aws_s3_bucket resource named "logs" was already declared at main.tf:1
- Error building ARM Config: obtain subscription from Azure CLI Terraform: Error: building AzureRM Client: obtaining subscription ID / Please run 'az login' to setup account
- Inconsistent conditional result types Terraform: Error: Inconsistent conditional result types — The true and false result expressions must have consistent types
Most viewed in Terraform
- Error acquiring the state lock Terraform: Error: Error acquiring the state lock — ConditionalCheckFailedException / state blob is already locked
- Inconsistent dependency lock file Terraform: Error: Inconsistent dependency lock file — provider x: required by this configuration but no version is selected
- Reference to undeclared resource Terraform: Error: Reference to undeclared resource / Reference to undeclared input variable
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026