command/show (json): marshal the state snapshot included with the plan file #21597
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.
A terraform planfile contains a state snapshot with certain resources updated
(those which get refreshed before plan, such as outputs and datasources).
Previously
terraform show -json $PLANFILE
was displaying the current state instead of the planfile's state.This caused an issue when the state included a
terraform_remote_state
datasource. The datasource's state gets refreshed - and therefore
upgraded to the current state version - during plan, but that won't
persist to state until apply.
In most cases, the json state parser can handle resources in state that haven't been upgraded yet. This particular problem is specific to
terraform_remote_state
datasources due to their unusual and unique schemas, which includecty.DynamicPseudoType
- the decoder could not translate the older flatmap-style state without a preciseType