Skip to content

Latest commit

 

History

History
84 lines (60 loc) · 3.12 KB

README.md

File metadata and controls

84 lines (60 loc) · 3.12 KB

Terraform Visual

CI Coverage Status

Terraform Visual is a simple but powerful tool to help you understand your Terraform plan easily.

Demo.gif

How to use it

Please note that this method uses the Terraform Visual version from original author. User interface may be different from other methods. I'll try to publish my own Github Pages in the future, but in the meanwhile the only way to use an online version is using original author Github Page.

For people who want to quickly experience how Terraform Visual looks like

  1. Generate Terraform plan in JSON format
$ terraform plan -out=plan.out                # Run plan and output as a file
$ terraform show -json plan.out > plan.json   # Read plan file and output it in JSON format
  1. Visit Terraform Visual

  2. Upload Terraform JSON to the platform

For people who don't like to upload Terraform plan to public internet. You can use Docker image as a CLI command.

  1. Pull docker image
# Using Yarn
$ docker pull ghcr.io/wiston999/terraform-visual:master
  1. Convert Terraform Plan into JSON File
$ terraform plan -out=plan.out                # Run plan and output as a file
$ terraform show -json plan.out > plan.json   # Read plan file and output it in JSON format
  1. Create Terraform Visual Report
$ docker run --rm -it \
  -v $(pwd)/plan.json:/tmp/plan.json -v $(pwd):/tmp \
  ghcr.io/wiston999/terraform-visual:master \
  terraform-visual --plan /tmp/plan.json --out /tmp
  1. Browse The Report
$ open terraform-visual-report/index.html

Using Docker

For people who likes Terraform Visual and want to integrate it into existing CI/CD pipeline.

The Docker image only includes Terraform visual CLI.

You can "install" Terraform Visual CLI into your existing CI/CD Docker image following these steps:

  1. Convert your Dockerfile to builder pattern. More info here

  2. Once your Dockerfile uses builder pattern, add

FROM ghcr.io/wiston999/terraform-visual:master as tfvisual

before the original FROM

  1. Add the following steps to your Dockerfile
COPY --from=tfvisual /usr/local/bin/node /usr/local/bin/node
COPY --from=tfvisual /usr/local/lib/node_modules/@terraform-visual /usr/local/lib/node_modules/@terraform-visual
COPY --from=tfvisual /usr/src/app /usr/src/app
RUN printf "===> Installing terraform-visual...\n" && \
  ln -sf /usr/src/app/bin/index.js /usr/local/bin/terraform-visual