A command-line utility to print the summary of the terraform plan
A command-line utility to print the summary of the terraform plan
tf-summarize is a command-line utility to print the summary of the terraform plan
If demo is slower for you, please see examples and screenshot for more details
go install github.com/dineshba/tf-summarize@latestbrew install tf-summarizeasdf plugin add tf-summarize
asdf install tf-summarize latestSee the asdf plugin source for more information.
docker run -v $PWD:/workspace -w /workspace ghcr.io/dineshba/tf-summarize -v # prints version
docker run -v $PWD:/workspace -w /workspace ghcr.io/dineshba/tf-summarize tfplan.json
docker run -v $PWD:/workspace -w /workspace ghcr.io/dineshba/tf-summarize -tree tfplan.json
# see example section for more examples
# add alias if needed
alias tf-summarize="docker run -v $PWD:/workspace -w /workspace ghcr.io/dineshba/tf-summarize"
tf-summarize tfplan.json
# see example section for more examplestf-summarize will accept tfplan directly. Docker based tf-summarize is not having terraform-binary to convert tfplan to json. So it only works with json files. If you want to use with tfplan directly, You can build a base image with terraform (use same version as tfplan created) and have our binary in it.
The below example uses kishaningithub/setup-tf-summarize
steps:
- uses: kishaningithub/setup-tf-summarize@v1For more customization options, kindly refer to the documentation here
cp tf-summarize /usr/local/bin/tf-summarize or to location which is part of $PATHmake build or go build -o tf-summarize .make install or cp tf-summarize /usr/local/bin/tf-summarize……The below example uses kishaningithub/setup-tf-summarize
name: Run tf-summarize
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: kishaningithub/setup-tf-summarize@v1
- name: Print tf-summarize version and help
run: |
tf-summarize -v
tf-summarize -hFor more customization options, kindly refer to the documentation here
Please refer this sample GitHub actions file and the sample runs here
Note: If you are using
hashicorp/setup-terraformGitHub action to set up terraform, ensure terraform_wrapper is set to false.
The below assumes that you have a stage called show in your codefresh.yaml example
We need to output the plan to json as there were some strange issues on codefresh when we used the tfplan file
A full example is available at example/codefresh/codefresh.yaml
TerraformPlan:
title: Terraform Plan
image: hashicorp/terraform:light
stage: plan
working_directory: "${{clone}}"
commands:
- terraform plan -out=tfplan
- terraform show -json tfplan > output.json
tfSummarize:
title: Show Changes
image: ghcr.io/dineshba/tf-summarize
stage: show
working_directory: "${{clone}}"
commands:
- tf-summarize output.json:warning: Not maintained by dineshba : The above example is maintained by userbradley - Any questions related please tag
@userbradleyon an issue
Refer this example to add comments in your PR. Sample comment added by github actions bot.
You can use tool fx to review the summary fo the terraform change
tf-summarize -json tfplan | fxNo open issues yet, or sync has not completed.