Invalid function argument Terraform Origin: Platform & cloud OSI layer 7 · Application Last updated 5 Nov 2026

Terraform: Error: Invalid function argument — Invalid value for "list" parameter: list of string required / Call to function "lookup" failed

A built-in function got a wrong type/value (empty list, missing key, wrong type).

Exact message you may see Error: Invalid function argumentInvalid value for "list" parameter: list of string requiredError: Error in function call: Call to function "lookup" failed: the given key does not exist in the given mapError: Invalid function argument Invalid value for "path" parameter: no file exists atCall to function "element" failed: cannot use element function with an empty list
Seen on: Terraform

Meaning

Read the function and parameter named. Common: element()/[0] on empty lists, lookup() without a default, file() path missing, tonumber("abc"), merge with null, join of non-strings. Test in terraform console. Use try(), coalesce(), lookup(map, key, default), length() guards.

Common causes

  • Indexing an empty list
  • lookup key missing and no default
  • file("path") doesn't exist
  • Type conversion failures
  • Passing null to functions requiring values

⚡ Quick fix

  1. lookup(var.map, key, null) / try(expr, default)
  2. Check lists with length(x) > 0 ? x[0] : null
  3. fileexists() before file()

Detailed fix by platform

Terraform

  1. terraform console then > lookup({a=1}, "b", 0)

How to diagnose

  1. Function — Which?
  2. Argument — Type/value?
  3. Guard — try/default?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

Error building ARM Config: obtain subscription from Azure CLI — Terraform: Error: building AzureRM Client: obtaining subscription ID / Please run 'az login' to setup account (Terraform)Error building ARM Co…Inconsistent conditional result types — Terraform: Error: Inconsistent conditional result types — The true and false result expressions must have consistent types (Terraform)Inconsistent conditio…Invalid AWS Region — Terraform: Error: Invalid AWS Region: us-east-3 / Error: configuring Terraform AWS Provider: validating provider credentials: operation error STS: GetCallerIdentity (Terraform)Invalid AWS RegionInvalid index: The given key does not identify an element — Terraform: Error: Invalid index — The given key does not identify an element in this collection value (Terraform)Invalid index: The gi…Invalid value for input variable — Terraform: Error: Invalid value for variable — "instance_type" must be a t3 type / The given value is not suitable for var.x declared at variables.tf:1,1-17: string required (Terraform)Invalid value for inp…No valid credential sources found (AWS provider) — Terraform: Error: No valid credential sources found — failed to refresh cached credentials, no EC2 IMDS role found / Error: configuring Terraform AWS Provider: no valid credential sources (Terraform)No valid credential s…No value for required variable — Terraform: Error: No value for required variable — The root module input variable "region" is not set, and has no default value (Terraform)No value for required…UnauthorizedOperation / AccessDenied during Terraform apply — Terraform: Error: creating EC2 Instance: UnauthorizedOperation: You are not authorized to perform this operation. User: arn:aws:iam::123:user/ci is not authorized to perform: ec2:RunInstances (Terraform)UnauthorizedOperation…Invalid f…

Explore the map of this error Full error map →

🧠 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.