Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jun 5, 2019

Conversation

mildwonkey
Copy link
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
command/show.go Outdated Show resolved Hide resolved
@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

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