terrafrom-report util back

This commit is contained in:
bluxmit 2021-08-29 20:41:56 +00:00
parent aaa4474d64
commit 289e27abbb
3 changed files with 28 additions and 2 deletions

26
utils/terraform-report.sh Normal file
View file

@ -0,0 +1,26 @@
#!/bin/bash
while getopts i:o: flag
do
case "${flag}" in
i) inventory=${OPTARG};;
o) output_dir=${OPTARG};;
esac
done
if [ -z "${output_dir}" ]; then output_dir="/home/static-server/terraform-reports/"; fi
project_name=${PWD##*/}
printf '%s\n' "project name - ${project_name}"
report_dir="${output_dir}/${project_name}/$(date +"%d-%m-%Y-%H-%M-%S")"
mkdir -p "$report_dir"
# terraform-docs
terrascan scan > ${report_dir}/terrascan.txt
# Terraform Graph
terraform graph | dot -Tsvg > .${report_dir}/graph.svg
# Terraform Visual
terraform plan -out=${report_dir}/plan.out
terraform show -json ${report_dir}/plan.out > ${report_dir}/plan.json
cd ${report_dir} && terraform-visual --plan ${report_dir}/plan.json

View file

@ -128,4 +128,4 @@ RUN echo "------------------------------------------------------ ansible ara" \
USER abc
COPY README.md /home/docs/docs/docs.md
COPY ./examples/terraform-scaleway /home/terraform
COPY ./examples/terraform-scaleway /home/examples/

View file

@ -9,7 +9,7 @@ Serves folder `/home/terraform`
In order to serve another terraform folder, for example `/home/project/my-terraform`
```
blast-radius --serve --port 8033 /home/project/my-terraform
blast-radius --serve --port 8030 /home/project/my-terraform
```
### [Terraform Visual](https://github.com/hieven/terraform-visual)