Terraform Plan Viewer for terraform show -json Output
Operator: Abdulla Al Fahad. How tools are built and checked
"Plan: 2 to add, 1 to change, 2 to destroy" is the last line of a plan that can run for thousands of lines, and the number that matters, why an instance is being replaced, sits somewhere in the middle. Load the JSON form of the plan here and each resource becomes one row: create, update in-place, replace, destroy or read, with a table of the attributes that differ and a tag on the attribute that forces a replacement.
In the built-in example the instance aws_instance.web[0] is replaced because its ami changed from ami-0aaa to ami-0bbb, the database aws_db_instance.main is updated in place with its password shown only as (sensitive value), a VPC in module.net is created with its id and arn marked (known after apply), and a bucket is destroyed.
The page reads what terraform show -json plan.tfplan writes. It does not run Terraform, read your state, or contact a provider, so it can only explain what the plan file already says.
Key features
- Create, update, replace, destroy, read, forget and no-op actions, with import markers
- Attribute-level diffs for nested blocks and lists, with 'known after apply' and masked sensitive values
- The attribute that forces a replacement flagged, taken from the plan's replace_paths
- Filters by action, resource type, module, data sources and free text over addresses and attribute names
- A Markdown summary with collapsible diff sections, cut to stay under GitHub's comment size limit, and a CSV of the changes
How the JSON plan maps to the list you see
Actions are read from each resource_changes entry. ["delete","create"] is a replacement that destroys first, ["create","delete"] is a replacement with create_before_destroy, and both count as one add and one destroy in the plan line, exactly as Terraform counts them. A resource with only ["no-op"] is listed but hidden from the Markdown. Output changes are shown in their own table.
Before and after values are flattened into dotted paths such as root_block_device[0].volume_size or tags.Env. A path is sensitive when before_sensitive or after_sensitive marks it, and then both sides are replaced by (sensitive value) in every view and in every export. A path is unknown when after_unknown marks it, and the after side reads (known after apply). Null values count as absent, so null to "x" is an addition. Each value is cut at 160 characters, a resource shows up to 400 attributes, and the list view shows the first 200 rows of a diff.
The Markdown escapes pipes, backticks and line breaks in table cells, wraps each diff in a fence that is longer than any sequence of backticks in its text, and escapes angle brackets in the summary line, because resource addresses can contain index keys written by someone else. The attribute sections stop at 60,000 characters, which leaves room under GitHub's 65,536-character limit for a comment.
How it works
The file is parsed as JSON and checked for a resource_changes array. The common wrong inputs get their own message: the zipped binary .tfplan, the human-readable plan text, and JSON from terraform show on a state file.
Each change is compared path by path between the flattened before and after trees, with the sensitive and unknown trees walked alongside so a masked or unknown value never reaches the output as a real one. Unchanged paths are kept in memory for filtering but not listed.
When this helps
- A reviewer filters a 600-resource plan to action: replace and sees that three aws_instance resources are replaced because user_data changed, which a quick read of the summary would have missed.
- A pipeline step posts the Markdown summary as a pull request comment, with the attribute sections collapsed so the comment stays short.
Opening a file
- Run terraform show -json plan.tfplan > plan.json, then drop plan.json here or paste its contents.
- Read the plan line and the counts, then filter to the actions or resource types you care about.
- Open a resource to see its attribute diff, or switch to Markdown for PR and copy the comment.
- Download the CSV if you want the changes in a spreadsheet.
Example
One resource_changes entry
{"address":"aws_instance.web[0]","type":"aws_instance","change":{"actions":["delete","create"],"before":{"ami":"ami-0aaa","instance_type":"t3.micro"},"after":{"ami":"ami-0bbb","instance_type":"t3.micro"},"after_unknown":{"id":true},"replace_paths":[["ami"]]},"action_reason":"replace_because_cannot_update"}The row it becomes
Plan: 1 to add, 0 to change, 1 to destroy.
replace aws_instance.web[0] (replace because cannot update)
ami "ami-0aaa" -> "ami-0bbb" forces replacement
id (known after apply)
instance_type is unchanged and is not listed.Tips for best results
- Filter to replace and destroy first: those are the actions that interrupt a running service, and the forces replacement tag shows the attribute to change if you want an in-place update instead.
- A resource listed as update with a single sensitive attribute often means a rotated secret; the values are hidden, but the row confirms that something changed.
- Use the search box on an attribute name, for example ami or security_groups, to find every resource whose plan touches it.
Limits
The JSON from terraform show contains sensitive values next to the flags that mark them. They are masked here, but the plan file itself, and any copy of it, is as sensitive as a state file.
Only the plan file's contents are shown. Changes outside Terraform (drift) are counted from resource_drift but not listed, and nothing says whether the apply will succeed.
A very large plan can hold thousands of resources; the list shows 100 at a time and the Markdown is cut at its character limit, so filter before copying a comment.
Common errors and how to fix them
- "This looks like a binary plan file (a .tfplan is a zip archive)"
- Convert it first: terraform show -json plan.tfplan > plan.json. The saved plan is a zip that only Terraform can read.
- "This is state output (terraform show -json with no plan file)"
- Without a plan file, terraform show prints the current state. Pass the plan file as the argument so the output holds resource_changes.
Best practices
- Post only the summary table to the pull request and keep the attribute sections for plans that touch a handful of resources.
- Review replacements against the forces replacement tag before approving; an unintended change to an immutable attribute shows up there.
Frequently asked questions
Why does a replace count as both an add and a destroy?
That is how Terraform's own plan line counts it: the old object is destroyed and a new one created. The viewer uses the same arithmetic, so its totals match the last line of terraform plan.