Skip to main content

Terraform Unsupported Argument Error: How to Fix

Key Takeaway

Fix the Terraform 'An argument named X is not expected here' error. Common causes include wrong provider version, deprecated arguments, typos, and wrong resource type.

Table of Contents

Quick Answer

The argument doesn’t exist for this resource in your provider version. Check for:

  1. Typo in the argument name
  2. Wrong provider version (argument added in newer version)
  3. Deprecated/removed argument (argument removed in newer version)
  4. Wrong resource type

The Error

Error: Unsupported argument

  on main.tf line 5, in resource "aws_instance" "web":
   5:   instance_tenancy = "default"

An argument named "instance_tenancy" is not expected here.

Cause 1: Typo

# ❌ Typo — "instace_type" instead of "instance_type"
resource "aws_instance" "web" {
  ami           = "ami-abc123"
  instace_type  = "t3.micro"    # Missing 'n'!
}

# ✅ Correct
resource "aws_instance" "web" {
  ami           = "ami-abc123"
  instance_type = "t3.micro"
}

Fix

Check the Terraform Registry documentation for the exact argument names.

Cause 2: Wrong Resource Type

# ❌ "instance_tenancy" belongs to aws_vpc, not aws_instance
resource "aws_instance" "web" {
  ami              = "ami-abc123"
  instance_type    = "t3.micro"
  instance_tenancy = "default"    # This is a VPC argument!
}

# ✅ Correct resource
resource "aws_vpc" "main" {
  cidr_block       = "10.0.0.0/16"
  instance_tenancy = "default"     # Correct here
}

Fix

Check the documentation for the specific resource type you’re using.

Cause 3: Provider Version Too Old

# This argument was added in AWS provider 5.40
resource "aws_eks_cluster" "main" {
  compute_config {
    enabled = true    # Added in 5.40 — fails on 5.30
  }
}
Error: Unsupported argument
An argument named "compute_config" is not expected here.

Fix

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.50"    # Upgrade to version that has the argument
    }
  }
}
terraform init -upgrade

Cause 4: Argument Removed in Newer Provider

# "tags" was moved from aws_s3_bucket to a separate resource
resource "aws_s3_bucket" "data" {
  bucket = "my-data"

  # ❌ Removed in AWS provider 4.x — use aws_s3_bucket_versioning instead
  versioning {
    enabled = true
  }
}

# ✅ Correct for AWS provider 4.x+
resource "aws_s3_bucket" "data" {
  bucket = "my-data"
}

resource "aws_s3_bucket_versioning" "data" {
  bucket = aws_s3_bucket.data.id
  versioning_configuration {
    status = "Enabled"
  }
}

Fix

Check the provider changelog for removed/migrated arguments.

Cause 5: Argument in Wrong Block

# ❌ "encrypted" is inside root_block_device, not at the top level
resource "aws_instance" "web" {
  ami           = "ami-abc123"
  instance_type = "t3.micro"
  encrypted     = true              # Wrong level!
}

# ✅ Correct nesting
resource "aws_instance" "web" {
  ami           = "ami-abc123"
  instance_type = "t3.micro"

  root_block_device {
    encrypted = true                 # Correct — inside the block
  }
}

Cause 6: Using Resource Arguments in Data Source

# ❌ Data sources have different arguments than resources
data "aws_instance" "web" {
  instance_type = "t3.micro"    # Not a filter — not supported here
}

# ✅ Data sources use filter blocks
data "aws_instance" "web" {
  filter {
    name   = "instance-type"
    values = ["t3.micro"]
  }
}

Debugging Steps

# 1. Check your provider version
terraform providers

# 2. Check the exact resource documentation
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance

# 3. Validate syntax
terraform validate

# 4. Format (catches some issues)
terraform fmt

Hands-On Courses

Conclusion

“Unsupported argument” almost always means one of five things: typo, wrong resource type, provider too old, argument removed in newer provider, or argument at the wrong nesting level. Check the Terraform Registry documentation for your specific resource and provider version. Run terraform validate to catch these errors before plan.

🚀

Level Up Your Terraform Skills

Hands-on courses, books, and resources from Luca Berton

Luca Berton
Written by

Luca Berton

DevOps Engineer, AWS Partner, Terraform expert, and author. Creator of Ansible Pilot, Terraform Pilot, and CopyPasteLearn.