Terraform Visual is a simple but powerful tool to help you understand your Terraform plan easily.
Using Terraform Visual
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
- 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
-
Visit Terraform Visual
-
Upload Terraform JSON to the platform
Using Docker image as CLI
For people who don't like to upload Terraform plan to public internet. You can use Docker image as a CLI command.
- Pull docker image
# Using Yarn
$ docker pull ghcr.io/wiston999/terraform-visual:master
- 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
- 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
- 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:
-
Convert your Dockerfile to builder pattern. More info here
-
Once your Dockerfile uses builder pattern, add
FROM ghcr.io/wiston999/terraform-visual:master as tfvisual
before the original FROM
- 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