How to fix Error: Unsuitable value type - string required in Terraform

TerraformBEGINNERMEDIUMUpdated Dec 30, 2025· 96 views

This error occurs when Terraform receives a value of the wrong type for an argument. It commonly happens when passing a list where a string is expected, or wrapping already-typed values in extra brackets.

Quick fix

Fixes Error: Unsuitable value type - string required

Error: Inappropriate value for attribute "name": string required
  1. Review the error message carefully
  2. Check if you're passing a list where a string is expected
  3. Remove unnecessary bracket wrapping
  4. Fix variable type declarations
terraform — error
Error: Inappropriate value for attribute "name": string required
Error: Unsuitable value type - string required

What this error means

Terraform is a strongly-typed language. Every resource argument, variable, and module input has a declared type (string, list, map, object, etc.). When you provide a value that doesn't match the expected type, Terraform raises an "unsuitable value type" error. This error most commonly occurs in three scenarios: 1. **Type Mismatch in Arguments**: You're passing a list value to an argument that expects a string, or vice versa. 2. **Wrapping Already-Typed Values**: You're unnecessarily wrapping a list in brackets (e.g., `["list_output"]` instead of just `list_output`). 3. **Nested Type Mismatches**: Object or map arguments have incompatible nested field types. The error message tells you exactly which argument needs fixing and what type is required.

Typical symptoms

  • Terraform plan or apply fails with 'unsuitable value type - string required'
  • Error message includes the argument name and expected type
  • Configuration worked in an older Terraform version (especially if upgrading from 0.11 to 0.12+)
  • Module or resource declarations that pass variables have type validation errors

Common causes

  1. Passing a list variable or output to an argument that expects a single string
  2. Wrapping a list output in extra brackets: `[module.vpc.private_route_table_ids]` when the output is already a list
  3. Removing the index from a list when a single value is needed: using `var.extensions` instead of `var.extensions[0]`
  4. Setting a variable default value that doesn't match the declared type constraint
  5. Terraform 0.12+ enforcing stricter type checking compared to 0.11

How to fix "Error: Unsuitable value type - string required"

1Review the error message carefully

The error will specify which argument is problematic and what type is required. For example:

bash
Error: Inappropriate value for attribute "name": string required

This tells you that the name argument expects a string, not the type you provided.

2Check if you're passing a list where a string is expected

If you're trying to pass a single item from a list, use indexing:

WRONG:

hcl
resource "aws_instance" "example" {
  subnet_id = var.subnet_ids  # List, but subnet_id expects a string
}

RIGHT:

hcl
resource "aws_instance" "example" {
  subnet_id = var.subnet_ids[0]  # Get first item from list
}

For dynamic selection, use element() function:

hcl
resource "aws_instance" "example" {
  subnet_id = element(var.subnet_ids, 0)
}
3Remove unnecessary bracket wrapping

If an output is already a list, don't wrap it in brackets:

WRONG:

hcl
resource "aws_route_table_association" "private" {
  route_table_id = ["module.vpc.private_route_table_ids"]  # Extra brackets!
}

RIGHT:

hcl
resource "aws_route_table_association" "private" {
  route_table_id = module.vpc.private_route_table_id  # Direct reference
}

When a resource expects multiple values (like a list), pass it directly without extra brackets.

4Fix variable type declarations

Ensure your variable type matches how you use it:

WRONG:

hcl
variable "database_name" {
  type    = string
  default = ["mydb"]  # Type says string but default is list!
}

RIGHT:

hcl
variable "database_name" {
  type    = string
  default = "mydb"  # Matches the declared type
}

Or if you need multiple values:

hcl
variable "database_names" {
  type    = list(string)
  default = ["mydb", "otherdb"]
}
5Use type conversion functions if needed

If you need to convert a list to a string (rarely necessary), Terraform provides functions:

hcl
# Join a list into a single string
resource "example" "test" {
  names = join(",", var.list_of_names)
}

# Convert to JSON for object arguments
resource "example" "test" {
  tags = jsonencode(var.tag_object)
}

Advanced notes

Terraform 0.12+ Migration Note: When upgrading from Terraform 0.11, type checking became much stricter. Configurations that worked before may need adjustment. Use terraform console to test expressions and verify their types before committing changes.

Type Conversion Strategy: While Terraform can automatically convert between numbers and strings in some cases, it cannot convert lists to strings. If you absolutely need string representation of a list, use jsonencode() or join() instead of relying on implicit conversion.

Module Outputs: When consuming module outputs, check the module's documentation for the exact output type. Module outputs can be strings, lists, maps, or objects—don't assume based on the output name.

Frequently asked questions

What does "Error: Unsuitable value type - string required" mean?
Terraform is a strongly-typed language. ). When you provide a value that doesn't match the expected type, Terraform raises an "unsuitable value type" error.
How do I fix "Error: Unsuitable value type - string required"?
This error occurs when Terraform receives a value of the wrong type for an argument. It commonly happens when passing a list where a string is expected, or wrapping already-typed values in extra brackets.
What causes "Error: Unsuitable value type - string required"?
Passing a list variable or output to an argument that expects a single string Wrapping a list output in extra brackets: [module.vpc.private_route_table_ids] when the output is already a list Removing the index from a list when a single value is needed: using var.extensions instead of var.extensions[0]
Is the "Error: Unsuitable value type - string required" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading