Skip to content

command/show (json): marshal the state snapshot included with the plan file#21597

Merged
mildwonkey merged 2 commits intomasterfrom
mildwonkey/b-show-plan-state
Jun 5, 2019
Merged

command/show (json): marshal the state snapshot included with the plan file#21597
mildwonkey merged 2 commits intomasterfrom
mildwonkey/b-show-plan-state

Conversation

@mildwonkey
Copy link
Copy Markdown
Contributor

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 include cty.DynamicPseudoType - the decoder could not translate the older flatmap-style state without a precise Type

The planfile contains a state snapshot with certain resources updated
(outputs and datasources). Previously `terraform show -json PLANFILE`
was using the current state instead of the state inside the plan as
intended.

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.
@mildwonkey mildwonkey requested a review from a team June 4, 2019 22:17
Comment thread command/show.go Outdated
@mildwonkey mildwonkey merged commit b9f114a into master Jun 5, 2019
@mildwonkey mildwonkey deleted the mildwonkey/b-show-plan-state branch June 5, 2019 11:29
@ghost
Copy link
Copy Markdown

ghost commented Jul 25, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants