alnoda-workspaces/workspaces/ansible-terraform-workspace/removeme_docs/terraform-tools.md
2022-05-23 09:36:06 +00:00

1.8 KiB

Terraform tools

Pre-commit hook

Blast-Radius

Serves folder /home/terraform

In order to serve another terraform folder, for example /home/project/my-terraform

blast-radius --serve --port 8030 /home/project/my-terraform

Terraform Visual

  • Generate Terraform plan in json
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
  • Generate Terraform-visual report
terraform-visual --plan plan.json

Terraform Graph

  • Create report
terraform graph | dot -Tsvg > graph.svg

Inframap

  • Visualize terraform state
inframap generate terraform.tfstate | dot -Tpng > graph.png

Rover

  • serve terraform visualisation
rover --workingDir /home/terraform

NOTE: Rover serves only on port 9000

UPDATE: made fork and configured to serve on any port

ISSUES: does not work, no resources displayed

In order to add Rover to the Workspace:

  • Include in Dockerfile
cd /tmp && curl -Lo ./terraform-rover.zip https://github.com/bluxmit/rover/releases/download/v1.6-cust/w1.7.zip \
&& unzip /tmp/terraform-rover.zip -d /tmp/rover && rm terraform-rover.zip  \
&& chmod +x /tmp/rover/rover \
&& mv /tmp/rover/rover /usr/bin/rover \
&& rm -rf /tmp/rover \
  • Include in supervisord-infra.conf
[program:rover]
directory=/home/terraform
command=/bin/sh -c " rover --workingDir /home/terraform --port 8031 "

Tutorials