tfparse
CLI tool to parse Terraform plan output into structured JSON.
Usage
# From file
tfparse plan.txt
# From stdin
terraform plan | tfparse
./zig/zig build plan -- ha-infra production | tfparseOutput Format
The tool outputs JSON with the following structure:
{
"summary": {
"add": 1,
"change": 0,
"replaced": 0,
"destroy": 0
},
"change_count": 1,
"resource_changes": [
{
"address": "google_compute_instance.example",
"action": "create",
"resource_type": "google_compute_instance",
"resource_name": "example",
"change": {
"before": {},
"after": {
"name": "example-instance",
"machine_type": "e2-medium"
}
}
}
]
}Fields
| Field | Description |
|---|---|
summary |
Counts of resources by action type |
change_count |
Total number of resource changes |
resource_changes |
Array of individual resource changes |
address |
Full Terraform resource address |
action |
One of: create, update,
destroy, replace |
resource_type |
Terraform resource type (e.g.,
google_compute_instance) |
resource_name |
Resource name from configuration |
replace_reason |
Reason for replacement (when applicable) |
change.before |
Resource attributes before the change |
change.after |
Resource attributes after the change |
Build
./zig/zig build tfparseThe binary will be output to ./bin/tfparse.
Make tool accessible from anywhere in your terminal
# build
./zig/zig build tfparse
# move
sudo mv ./bin/tfparse /usr/local/bin/tfparse
# now accessible globally
which tfparse