From b480343798982213abb7f803db76348d47b205a9 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Wed, 11 Dec 2024 11:41:21 -0800 Subject: [PATCH] rfc: Static Evaluation of Provider Iteration state tracking revision The original proposal called for the state snapshot writer to generate a resource-level provider property if all of the instances of the resource had the same provider instance address, regardless of what that address actually is. The actual implementation instead chose to generate the resource-level property only if none of the instances of the resource refer to a provider instance that has an instance key. Signed-off-by: Martin Atkins --- rfc/20240513-static-evaluation-providers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfc/20240513-static-evaluation-providers.md b/rfc/20240513-static-evaluation-providers.md index 9105f1eaf0..ac60520bd8 100644 --- a/rfc/20240513-static-evaluation-providers.md +++ b/rfc/20240513-static-evaluation-providers.md @@ -752,7 +752,7 @@ The current version of [the OpenTofu v1.x Compatibility Promises](https://opento An older version of OpenTofu would not be able to successfully load a state snapshot without a resource-level `"provider"` property, which would therefore be an example of "new features that earlier versions cannot understand". However, we try to avoid blocking downgrades whenever possible notwithstanding the above statements, because downgrading back to an earlier version shortly after upgrading can be a helpful workaround for newly-introduced bugs. -As a compromise then, the state snapshot _writer_ will generate instance-level `"provider"` properties only if there's at least one instance with a different provider instance address than the others. If all instances of a particular resource have the same provider instance address then the writer will instead generate a resource-level `"provider"` property containing that single provider instance address. This means that any configuration that is not using the new features proposed in this RFC will continue to generate state snapshots that are backward-compatible with previous versions of OpenTofu (notwithstanding any other unrelated changes to the state snapshot format outside the scope of this RFC). +As a compromise then, the state snapshot _writer_ will generate instance-level `"provider"` properties only if there's at least one instance that has an instance key. If all instances of a particular resource select the same no-key provider instance address then the writer will instead generate a resource-level `"provider"` property containing that single provider instance address. This means that any configuration that is not using the new features proposed in this RFC will continue to generate state snapshots that are backward-compatible with previous versions of OpenTofu (notwithstanding any other unrelated changes to the state snapshot format outside the scope of this RFC). The state snapshot loader will parse both the resource-level address and the instance-level addresses and determine which to use for each resource instance. It will, for now, return an error if any of the instance addresses are not identical aside from the optional trailing instance key. This preserves our current simplification of each resource still being bound to exactly one provider configuration while offering a more general syntax that we can retain in future if we weaken that constraint. We don't yet know exactly what flexibility we will need for future features, and so capturing the entire provider instance address (and then verifying their consistency) gives us the freedom to refer to literally any valid provider instance address in future versions, without changing the syntax and thus without the need for new state snapshot format upgrade logic.