The apply has been running for 3 minutes and 40 seconds. Eleven resources print Creation complete, and the twelfth stops with a red block: Error: Provider produced inconsistent result after apply. Under it sits the address aws_iam_role.ci_deployer, the phrase "Root resource was present, but now absent", and a closing sentence saying this is a bug in the provider which should be reported in the provider's own issue tracker.
You now have two questions. Is the role in AWS? And does Terraform know about it? They have different answers more often than people expect, and what you type next depends on the combination. Getting it wrong is how a single error becomes a duplicate role, an orphaned DNS record or a state file nobody trusts.
What the error checks, and why the cloud object usually survives it
Terraform core does not call cloud APIs. It sends the provider a planned object, the provider performs the create or update, and the provider returns the new object. Core then compares the two. Every attribute that was known at plan time must come back with exactly the same value; attributes planned as unknown, shown as (known after apply), may come back as anything. One mismatch and you get this error.
The order matters. The comparison runs after the API call returned success, so in most cases the object exists in the cloud. What differs is the record. When the provider returns an object with a changed attribute, Terraform still persists what the provider returned, so the resource is tracked with the provider's value. When the provider returns null, which is what "present, but now absent" means, there is nothing to record: the role exists in AWS and is missing from state.
Planned value: the attribute value Terraform committed to during plan. Known planned values are a promise; the provider may not break it during apply.
New state: the object the provider returns from the apply call. It is what lands in the state file, even when the check fails.
Legacy SDK tolerance: providers built on terraform-plugin-sdk/v2 cannot always describe their schemas precisely, so for them core downgrades this check to a warning in the debug log, with the text "but we are tolerating it because it is using the legacy plugin SDK". Resources built on terraform-plugin-framework get the hard error.
Inconsistent final plan: a sibling error, raised before the API call when a value that was unknown at plan time resolves to something incompatible. Different timing, different recovery: nothing was created yet.
That third term explains a pattern that confuses teams. A configuration works for two years, someone bumps the AWS provider by one major version, and a resource that was silently tolerated now fails loudly, because that resource moved from SDKv2 to the framework in the new release. Nothing in your code changed. The provider's honesty did.
Five edge cases that produce the same red block
The error text is identical across very different root causes, so read the attribute path and the "was" and "now" values before guessing. In practice the cases sort into five groups.
The first is eventual consistency. The create call succeeds, the provider immediately reads the object back, and the read returns 404 because the API has not propagated it yet. AWS IAM and Route 53 are the classic examples; Microsoft Entra objects and some Google Cloud IAM bindings behave similarly.
Providers wrap these reads in retry loops, but the loops have fixed limits, and a slow region or a throttled account at 2 a.m. can outlast them. This is the "Root resource was present, but now absent" variant, and a second apply a minute later usually reports that the object already exists.
The second is normalisation. You send one form, the API stores a canonical form. A CIDR of 10.0.1.5/24 comes back as 10.0.1.0/24. A DNS name gains a trailing dot. A policy document returns with keys reordered, whitespace removed or a single-element list collapsed to a string. An ID you passed in upper case returns in lower case. The error shows was cty.StringVal("...") and but now cty.StringVal("...") with two strings that mean the same thing to the API and differ byte for byte to Terraform.
The third is server-side defaults. You leave an optional attribute unset, the plan records null, and the API fills in a default such as a 7 day retention or a STANDARD tier. If the schema marks the attribute Optional but not Computed, null was a known planned value, and any filled-in value breaks the promise.
The fourth is tag merging. The AWS provider combines default_tags from the provider block with resource tags into tags_all. Identical keys at both levels, empty-string values and tags added by AWS itself have produced inconsistency errors across several provider versions, sometimes at plan, sometimes after apply.
The fifth is identity inside sets. Nested blocks stored as sets are identified by their full contents, so if the API adds or alters one field in one element, Terraform sees a different element and reports the whole set as inconsistent. Security group rules and load balancer listener actions are frequent offenders.
A recovery procedure that leaves state and cloud in agreement
The goal is not to make the red block disappear. It is to end with state and cloud describing the same objects. Work in this order.
- Stop any automatic retry. Copy the full error, the resource address, the attribute path and both values into the incident notes before the CI log rotates.
- Check the cloud directly with the provider's CLI or console, for example
aws iam get-role --role-name ci-deployer. Write down whether the object exists and its real attribute values. - Check state with
terraform state listfiltered by the address, thenterraform state showon it. You now know which of four combinations you are in. - If the object is in both, run
terraform plan. A diff on the reported attribute means normalisation or a default: change your configuration to the canonical value the API returned, such as the network address instead of a host address, or build policies withjsonencodeor theaws_iam_policy_documentdata source. - If the object is in the cloud but not in state, add an
importblock (available since Terraform 1.5) or runterraform import, then plan until it shows no changes for that address. - If it is in state but not in the cloud, run
terraform apply -refresh-only, review what it drops, and then a normal plan will recreate it. - If it is in neither, a plain retry is safe. For propagation races, a retry after 60 to 120 seconds is usually enough.
- When the same resource fails twice, rerun with
TF_LOG_PROVIDER=DEBUGandTF_LOG_PATHset, search the log for the attribute, and check the provider's changelog for that resource name across the versions between your pin and the latest release. - If a minimal configuration still reproduces it on the latest provider, open an issue with the Terraform version, the provider version and that configuration. The error message is right that the provider owns the fix.
Four mistakes undo this work more often than the error itself:
- Adding
lifecycle { ignore_changes = [...] }for the attribute. It suppresses diffs during plan and does nothing for the post-apply check. - Running
terraform state rmto "clear" the resource. You create the in-cloud-not-in-state case on purpose, and the next apply builds a second copy where the API allows duplicates. - Wrapping apply in a CI loop with 3 automatic retries. For resources with generated names, such as anything using
name_prefix, each loop can leave one more orphan behind. - Downgrading the provider to the last version that "worked" without checking state. State written by the newer provider can carry a newer schema version, and the older binary refuses it with "Resource instance managed by newer provider version".
Questions engineers ask about this provider error
Does lowering parallelism help? Sometimes. Terraform runs 10 operations at once by default, and -parallelism=1 or 2 can hide races between dependent resources that hit the same eventually consistent API. It slows a large apply by several times, so treat it as a diagnostic, not a fix.
Will a time_sleep resource fix it? time_sleep from the hashicorp/time provider inserts a wait between two resources, which helps when a dependent resource reads too early. It cannot help when the provider's own read right after create fails, because that happens inside one resource's apply.
Does OpenTofu behave the same way? Yes. OpenTofu forked from Terraform 1.5 in 2023 and kept the same post-apply consistency check and the same wording, so the diagnosis and recovery steps carry over unchanged.
How do I know which SDK a resource uses? Read the provider's go.mod and its resource source. Large providers such as the AWS one are muxed with terraform-plugin-mux, so the answer is per resource: some run on the framework and some on SDKv2 in the same binary.
Expect to see this error more over the next few provider releases, not less. Every resource that moves from SDKv2 to the framework loses the legacy tolerance, so mismatches that were written quietly into state for years will surface as hard failures.
That is a better deal than it looks: a loud failure on day one costs an hour, while silent drift found during an incident costs far more. It is also the kind of state reasoning that platform engineering interviews in Lisbon and Porto like to probe. Keep the four-combination check as a runbook entry, and the next red block takes 15 minutes.