Skip to main content
DevOps Insightsguides & answers

Terraform · intermediate

Terraform Identity Errors After a Provider Upgrade

Short answer

"Missing Resource Identity After Read" and "Unexpected Identity Change" come from the provider, not from your configuration, and they usually start the day you upgrade it. Upgrade again with terraform init -upgrade, because these have been fixed within days. If the newest release still fails, exclude the broken version in your version constraint, or pin the last one that worked, and commit the dependency lock file (which records the exact provider version you use). Do not start by editing state by hand, such as removing resources and importing them again.

N
Neeraj Jha
3 min read
On this page · 3 sections
Diagram of How an upgrade breaks every plan: 1. Provider upgrade, 2. Identity support changes, 3. Existing resources read, 4. Every plan fails, 5. Next release or a pin.

What resource identity is

Since Terraform 1.12, a provider can store a small identity for each resource next to its settings in state, the record of what Terraform has built,: the few values that pin down exactly which real object it is, such as its name, account and region. It must never change while the object exists. The provider checks it on every read.

When a release gets that check wrong for one resource type, every resource of that type fails, with one of these:

text
Error: Missing Resource Identity After Read: The Terraform provider unexpectedly
returned no resource identity after having no errors in the resource read.

Error: Unexpected Identity Change: During the read operation, the Terraform
Provider unexpectedly returned a different identity then the previously stored one.

Both messages go on to say that this is always a problem with the provider, and they are right. The checks are in the libraries (SDKs) that providers are built with, not in Terraform itself. That is why they can appear even if you run an older Terraform.

How an upgrade breaks every plan

1. Provider upgrade. terraform init -upgrade selects a new release.

1 / 5

What fixed it in practice

In the AWS provider each case so far was a one-release bug: aws_network_acl_rule broke in 6.59.0 and was fixed in 6.60.0; aws_ssm_parameter names with a leading slash broke in 6.58.0 and were fixed in 6.59.0. So:

bash
terraform init -upgrade
terraform plan

If that still fails, exclude the bad version and keep the rest of your constraint:

hcl
version = ">= 6.0, != 6.59.0"

Then search the provider's issues for the resource type and the message; if nobody has reported it, report it with both identities from the error.

What not to do

Removing a resource from state and importing it again by hand can attach the wrong real object. Back up state before any state command, and prefer the provider fix.

The full page is Missing Resource Identity After Read. Upgrades that break plans for other reasons are covered by the dependency lock file page.

Tagged with

Enjoyed this article?

Get more DevOps insights delivered to your inbox.

Get new posts by email

Subscribe to get an email when a new blog post is published. Skip anytime.

No spam, unsubscribe anytime.

N

Written by

Neeraj Jha

Platform administrator and lead writer.

View all posts →

Discussion

0 comments

Sign in to join the conversation.

Be the first to comment

Start a conversation about this post

Share: