https://github.com/jalseth/tfplan-origins
A utility to map resources in a Terraform plan back to their origin source files.
https://github.com/jalseth/tfplan-origins
Last synced: 4 months ago
JSON representation
A utility to map resources in a Terraform plan back to their origin source files.
- Host: GitHub
- URL: https://github.com/jalseth/tfplan-origins
- Owner: jalseth
- License: mit
- Created: 2025-10-19T18:00:40.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2026-03-14T22:19:24.000Z (4 months ago)
- Last Synced: 2026-03-15T07:20:11.342Z (4 months ago)
- Language: Go
- Size: 26.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tfplan-origins
A utility to map resources in a Terraform plan back to their origin source files.
## Output format
The enriched plan is the standard Terraform plan JSON with a `_loc` field added to each resource change, pointing to the source file and line where the resource is defined:
```json
{
"resource_changes": [
{
"address": "aws_s3_bucket.example",
"_loc": {
"file": "infra/main.tf",
"line": 12
},
...
}
]
}
```
## GitHub Action
The easiest way to use `tfplan-origins` is via the GitHub Action. It builds the tools from source and enriches your Terraform plan JSON with source file locations.
```yaml
- name: 'create plan'
working-directory: 'infra'
run: |
terraform init
terraform plan -out=plan.bin
terraform show -json plan.bin > plan.json
- name: 'enrich plan with origins'
id: 'origins'
uses: 'jalseth/tfplan-origins@main'
with:
terraform-dir: 'infra'
plan-json: 'infra/plan.json'
- name: 'use enriched plan'
run: cat '${{ steps.origins.outputs.enriched-plan-file }}'
```
### Inputs
| Input | Required | Default | Description |
|-------|----------|---------|-------------|
| `plan-json` | yes | | Path to the Terraform plan JSON (output of `terraform show -json`) |
| `terraform-dir` | no | `.` | Root Terraform config directory |
| `output-file` | no | `enriched_plan.json` | Path where the enriched plan JSON will be written |
| `go-version` | no | `1.25` | Go version used to build the tools |
| `cache` | no | `true` | Cache the built binaries between runs |
### Outputs
| Output | Description |
|--------|-------------|
| `enriched-plan-file` | Absolute path to the enriched plan JSON |