What Terraform is checking
Terraform plans, then applies, and only values shown as (known after apply) are allowed to change between the two. Everything you could see in the plan must come back exactly as planned. When it does not, you get this:
Error: Provider produced inconsistent result after apply
When applying changes to aws_example.this, provider
"registry.terraform.io/hashicorp/aws" produced an unexpected
new value: .name: was cty.StringVal("MyName"), but now
cty.StringVal("myname").
That was … but now … detail is the whole diagnosis. If the two values differ only in case, order, spacing or JSON formatting, the API normalised your input.
1. Plan. The provider promises name = "MyName", taken from your configuration.
Fix it in this order
- Match the value the API returns. Use the exact case and order from the
but nowvalue. For policies and other JSON documents, build them withjsonencode()rather than a hand-formatted string. - Upgrade the provider with
terraform init -upgrade. These mismatches get fixed resource by resource. If the error started right after an upgrade, pin the last version that worked instead. - Deal with the tainted resource. On a failed create, Terraform still saves the object, marked tainted, so the next plan says it "is tainted, so must be replaced". If the real object is fine, keep it:
terraform untaint 'aws_example.this'
terraform plan
The plan should now show no replacement. For a database, read that plan carefully before applying anything: a replacement would destroy the existing one.
Why newer resources hit it more
For resources built on the older plugin SDK, Terraform only writes a warning to the log for the same mismatch. Resources built on the newer plugin framework get the error. So a brand-new resource type is where you are most likely to see it.
The full page, with a decision tree, is Provider produced inconsistent result after apply. Its close relative, an identity error after a provider upgrade, is covered on the resource identity 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.
Related Posts
Discussion
0 comments
Sign in to join the conversation.
Be the first to comment
Start a conversation about this post


