gableroux/terraform-graphviz
Docker image to use terraform
and graphviz to make it easier to generate graphs with terraform :+1:
docker run --rm -it \
--workdir=/app \
-v "$PWD:/app" \
-v "$HOME/.aws:/root/.aws/" \
-v "$HOME/.ssh:/root/.ssh/" \
gableroux/terraform-graphviz:0.12.24
sh -c "terraform graph -draw-cycles | dot -Tsvg -o graph.svg"
docker-compose.yml
exampleversion: '3'
services:
# official terraform image
terraform:
image: hashicorp/terraform:0.12.24
env_file: .env
volumes:
- "$PWD:/app"
- "$HOME/.aws:/root/.aws/"
- "$HOME/.ssh:/root/.ssh/"
working_dir: /app
# image based on official image with graphviz addition, only use when you when you want ot generate graphs
terraform-graphviz:
image: gableroux/terraform-graphviz:0.12.24
env_file: .env
volumes:
- "$PWD:/app"
- "$HOME/.aws:/root/.aws/"
- "$HOME/.ssh:/root/.ssh/"
.gitlab-ci.yml
exampleThis will run validate
against your terraform code, quite useful and quick to run in a CI (uses official terraform image).
stages:
- test
terraform_validate:
stage: test
image: hashicorp/terraform:0.12.24
script:
- cp .env.example .env
- terraform init
- terraform validate -check-variables=true # don't require aws credentials
There is a script in scripts
that reads values from versions.txt
and runs required commands to push to the repository with tags and trigger docker hub. :v:
Installing directly for your distro is fine, but pulling this image is faster. You should use the official hashicorp/terraform docker container when you can.
You should indeed use the official hashicorp/terraform docker container. In my case, I also wanted to have graphviz
installed so it to generate terraform graphs. It's probably better to stick to the original one.
Fork the project, replace version in FROM image and push your own image.
Yes, why not?
I don't trust people when it comes to running critical code against infrastructure. If you wish to use this, I recommend you to fork it and build your own.
I'm using docker's automated build
docker pull gableroux/terraform-graphviz