# Terraform: "Provider produced inconsistent final plan" during plan
## What you are seeing
```
Error: Provider produced inconsistent final plan
When expanding the plan for aws_db_instance.main to include new values
learned so far during apply, provider "registry.terraform.io/hashicorp/aws"
changed the planned action for ...
```
This fires during plan, not apply. The provider first planned one set of changes, then during the plan walk learned new values (from other resources) and produced a contradictory final plan.
## First response
1. Look at which resource and attribute flipped. Common trigger: a computed value from resource A feeds resource B, and the provider cannot decide B's plan until A is known. Restructuring to break the feedback loop often fixes it.
2. Simplify: replace complex expressions (nested conditionals, dynamic blocks keyed on computed values) with plainer config and re-plan. If the error disappears, bisect back to the offending expression.
3. Check the provider version. Planning-logic bugs get fixed; upgrading the provider resolves a real share of these.
## Rules for agents
1. This is not fixed by applying. Applying cannot proceed because planning never completes.
2. Do not paper over it with `-target`. Targeted applies on a broken plan just move the failure.
3. `depends_on` does not fix planning contradictions; it only orders operations. Adding depends_on to an inconsistent plan is superstition.
4. If the inconsistency involves a module output feeding back into the same module's input, that is a design smell. Break the cycle with a data source or a second apply stage.