Resource pre-planned private data #37986
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add ability to forward PlannedPrivate data between plans
Terraform providers sometimes want to be able to plan a computed field which may not be deterministically generated. For example, a random GUID could be generated during plan, making the overall Terraform plan more precise, but there is currently no way to carry that planned value forward to apply.
The problem is that there are always two entirely independent plans for every resource change. Terraform compares these two plans for consistency, so a provider may not return a different computed value, but there is no way for the provider to see what the prior planned value was. This means that a planned value which is not reproducible from the given inputs is not plan-able at all.
This PR allows Terraform to take the private data from the first plan, which is usually discarded, and send it along in the second plan request. The provider can then use that data to recreate any previously planned values, either because they are stored directly, or contain enough seed data to recreate the same result.
We require a new client capability flag for this as well. The server needs to know whether it can rely on the planned private data being returned before it can create a plan depending on that behaviour, so the client must advertise that it intends to do so n the initial request.