Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Linter
uses: docker://morphy/revive-action:v2

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ example/tfplan

cover.out
cover.html
*.cov
*.cov
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ linters:
enable:
- gofmt
- goimports
- golint
- golint
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3.12

default_stages: [pre-commit, pre-push]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-merge-conflict
exclude: '.*\.go$'
- id: end-of-file-fixer
exclude: '.*\.go$'
- id: trailing-whitespace
exclude: '.*\.go$'
- id: check-yaml
exclude: '.*\.go$'
- id: check-added-large-files
args: ['--maxkb=500']
exclude: '.*\.go$'
- id: detect-private-key
exclude: '.*\.go$'
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.43.0
hooks:
- id: markdownlint
args:
- --fix
verbose: true
entry: bash -c 'markdownlint "$@" || true' --
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
68 changes: 38 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
`tf-summarize` is a command-line utility to print the summary of the terraform plan

<!-- TOC -->
* [tf-summarize (Terraform Summarizer)](#tf-summarize-terraform-summarizer)
* [Demo](#demo)
* [Why do we need it ?](#why-do-we-need-it-)
* [Install](#install)
* [Using Go](#using-go)
* [Using Brew](#using-brew)
* [Using asdf](#using-asdf)
* [Using Docker](#using-docker)
* [Using Github action](#using-github-action)
* [Download zip in release page](#download-zip-in-release-page)
* [Clone and Build Binary](#clone-and-build-binary)
* [Usage](#usage)
* [Examples](#examples)
* [GitHub Actions Workflow](#github-actions-workflow)
* [Using setup-tf-summarize action](#using-setup-tf-summarize-action)
* [Other approach](#other-approach)
* [Codefresh example](#codefresh-example)
* [Comment terraform plan summary in PRs](#comment-terraform-plan-summary-in-prs)
* [Interactive summary review](#interactive-summary-review)
* [Screenshot](#screenshot)
* [TODO](#todo)
* [tf-summarize (Terraform Summarizer)](#tf-summarize-terraform-summarizer)
* [Demo](#demo)
* [Why do we need it ?](#why-do-we-need-it-)
* [Install](#install)
* [Using Go](#using-go)
* [Using Brew](#using-brew)
* [Using asdf](#using-asdf)
* [Using Docker](#using-docker)
* [Using Github action](#using-github-action)
* [Download zip in release page](#download-zip-in-release-page)
* [Clone and Build Binary](#clone-and-build-binary)
* [Usage](#usage)
* [Examples](#examples)
* [GitHub Actions Workflow](#github-actions-workflow)
* [Using setup-tf-summarize action](#using-setup-tf-summarize-action)
* [Other approach](#other-approach)
* [Codefresh example](#codefresh-example)
* [Comment terraform plan summary in PRs](#comment-terraform-plan-summary-in-prs)
* [Interactive summary review](#interactive-summary-review)
* [Screenshot](#screenshot)
* [TODO](#todo)
<!-- TOC -->
### Demo

Expand All @@ -38,23 +38,26 @@ If demo is slower for you, please see [examples](#examples) and [screenshot](#sc

### Why do we need it ?

- Most of the time, we make changes to the terraform files or tf-var files and run the plan command. And we precisely know which resources will get affected. In those time, we would like to just see the resource name and it's change.
- When our plan have more than say 10 changes, we will first see what are the deleted changes, or we will just see the list of resources that get affected.
* Most of the time, we make changes to the terraform files or tf-var files and run the plan command. And we precisely know which resources will get affected. In those time, we would like to just see the resource name and it's change.
* When our plan have more than say 10 changes, we will first see what are the deleted changes, or we will just see the list of resources that get affected.

### Install

#### Using Go

```sh
go install github.com/dineshba/tf-summarize@latest
```

#### Using Brew

```sh
brew tap thecasualcoder/stable
brew install tf-summarize
```

#### Using asdf

```sh
asdf plugin add tf-summarize
asdf install tf-summarize latest
Expand All @@ -63,6 +66,7 @@ asdf install tf-summarize latest
> See the asdf [plugin source](https://github.com/adamcrews/asdf-tf-summarize#install) for more information.

#### Using Docker

```sh
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
Expand Down Expand Up @@ -91,12 +95,14 @@ steps:
For more customization options, kindly refer to the [documentation here](https://github.com/kishaningithub/setup-tf-summarize#usage)

#### Download zip in release page

1. Go to release page [https://github.com/dineshba/terraform-plan-summary/releases](https://github.com/dineshba/terraform-plan-summary/releases)
2. Download the zip for your OS and unzip it
3. Copy it to local bin using `cp tf-summarize /usr/local/bin/tf-summarize` or to location which is part of `$PATH`
4. (For Mac Only) Give access to run if prompted. [Refer here](https://stackoverflow.com/a/19551359/5305962)

#### Clone and Build Binary

1. Clone this repo
2. Build binary using `make build` or `go build -o tf-summarize .`
3. Install it to local bin using `make install` or `cp tf-summarize /usr/local/bin/tf-summarize`
Expand Down Expand Up @@ -200,7 +206,7 @@ A full example is available at [`example/codefresh/codefresh.yaml`](/example/cod
commands:
- terraform plan -out=tfplan
- terraform show -json tfplan > output.json

tfSummarize:
title: Show Changes
image: ghcr.io/dineshba/tf-summarize
Expand All @@ -210,25 +216,27 @@ A full example is available at [`example/codefresh/codefresh.yaml`](/example/cod
- tf-summarize output.json
```

> :warning: **Not maintained by [dineshba](https://github.com/dineshba)** : The above example is maintained by [userbradley](https://github.com/userbradley) - Any questions related please tag `@userbradley` on an issue
> :warning: **Not maintained by [dineshba](https://github.com/dineshba)** : The above example is maintained by [userbradley](https://github.com/userbradley) - Any questions related please tag `@userbradley` on an issue

#### Comment terraform plan summary in PRs

Refer [this example](https://github.com/dineshba/tf-summarize/blob/demo-pr/.github/workflows/demo.yml#L61-L73) to add comments in your PR. Sample [comment](https://github.com/dineshba/tf-summarize/pull/19#issuecomment-1295882938) added by github actions bot.

#### Interactive summary review

You can use tool [fx](https://github.com/antonmedv/fx) to review the summary fo the terraform change
You can use tool [fx](https://github.com/antonmedv/fx) to review the summary of the terraform change

```sh
tf-summarize -json tfplan | fx
```

### Screenshot

![screenshot](example/tf-summarize-screenshot.png)

### TODO

- [x] Read terraform state file directly. (Currently need to convert to json and pass it)
- [ ] Directly run the terraform plan and show the summary
- [ ] Able to show summary of the current terraform state
- [x] Include version subcommand in binary
* [x] Read terraform state file directly. (Currently need to convert to json and pass it)
* [ ] Directly run the terraform plan and show the summary
* [ ] Able to show summary of the current terraform state
* [x] Include version subcommand in binary
2 changes: 1 addition & 1 deletion example/codefresh/codefresh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ steps:
commands:
- terraform plan -out=tfplan
- terraform show -json tfplan > output.json

tfSummarize:
title: Show Changes
image: ghcr.io/dineshba/tf-summarize
Expand Down
36 changes: 18 additions & 18 deletions example/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,44 @@ config:
# the default is bash for Linux
# or powershell.exe for Windows
command: bash -l

# Specify the current working directory path
# the default is the current working directory path
cwd: /private/tmp/terraform-plan-summary

# Export additional ENV variables
env:
recording: true

# Explicitly set the number of columns
# or use `auto` to take the current
# number of columns of your shell
cols: 212

# Explicitly set the number of rows
# or use `auto` to take the current
# number of rows of your shell
rows: 57

# Amount of times to repeat GIF
# If value is -1, play once
# If value is 0, loop indefinitely
# If value is a positive number, loop n times
repeat: 0

# Quality
# 1 - 100
quality: 100

# Delay between frames in ms
# If the value is `auto` use the actual recording delays
frameDelay: auto

# Maximum delay between frames in ms
# Ignored if the `frameDelay` isn't set to `auto`
# Set to `auto` to prevent limiting the max idle time
maxIdleTime: 2000

# The surrounding frame box
# The `type` can be null, window, floating, or solid`
# To hide the title use the value null
Expand All @@ -55,7 +55,7 @@ config:
border: 0px black solid
# boxShadow: none
# margin: 0px

# Add a watermark image to the rendered gif
# You need to specify an absolute path for
# the image on your machine or a URL, and you can also
Expand All @@ -68,25 +68,25 @@ config:
bottom: 15px
width: 100px
opacity: 0.9

# Cursor style can be one of
# `block`, `underline`, or `bar`
cursorStyle: block

# Font family
# You can use any font that is installed on your machine
# in CSS-like syntax
fontFamily: "Monaco, Lucida Console, Ubuntu Mono, Monospace"

# The size of the font
fontSize: 14

# The height of lines
lineHeight: 1

# The spacing between letters
letterSpacing: 0

# Theme
theme:
background: "transparent"
Expand All @@ -108,7 +108,7 @@ config:
brightMagenta: "#ae89fe"
brightCyan: "#b1c6ca"
brightWhite: "#f9f9f4"

# Records, feel free to edit them
records:
- delay: 5739
Expand Down Expand Up @@ -356,7 +356,7 @@ records:
- delay: 1303
content: '# result is grouped by Change'
- delay: 2430
content: "\r\n\e[?2004l\r"
content: "\r\n\e[?2004l\r"
- delay: 140
content: "\e[1;32m❯\e[0m "
- delay: 1303
Expand Down
2 changes: 1 addition & 1 deletion example/github/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ variable "description" {

variable "topics" {
type = list(string)
}
}