Introduction
Problem
This guide explains how to resolve the Error: Unsupported attribute or Failed to persist state: unsupported attribute "..." error in Terraform. This error typically occurs after a provider version update, causing a mismatch between your configuration, the provider's code, and the existing state file.
This error can cause terraform plan or apply commands to fail and may lock your workspace in Terraform Cloud or Enterprise.
Cause
The root cause is a schema mismatch following a provider upgrade.
- Breaking Change: A new version of a provider was released, which removed or renamed an attribute.
-
Unpinned Version: Your Terraform configuration did not have a strict version constraint (e.g.,
version = ">= 2.0.0"). -
Automatic Upgrade: The next
terraform initrun automatically downloaded this new, incompatible provider version. - Schema Mismatch: The new provider code tries to read the old state file and fails when it finds the old, "unsupported" attribute.
Overview of possible solutions
Solutions:
You have two main options to fix this: a quick provider version rollback (short-term) or upgrading your code (long-term).
-
Solution 1: Pin Provider to the Previous Working Version
This is the fastest way to your workspace. You force Terraform to use the older provider version that matches your state file.Edit
versions.tf: In yourrequired_providersblock, update the version constraint to lock it to the last known-good major version. Solution 2: Upgrade Code to Match the New Provider Resources Configurations
You can update your configuration to use the new attributes/arguments if you are upgrading the provider intentionally.- Check Upgrade Guide: Find the official upgrade guide for the new provider version to see what changed.
-
Update HCL Code: Modify your
.tffiles to use the new, supported attributes.
Outcome
After applying either solution, running terraform plan should complete successfully without the "unsupported attribute" error.