Skip to content

🌏 Docker image to use terraform and graphviz to make it easier to generate graphs with terraform πŸ‘

License

Notifications You must be signed in to change notification settings

GabLeRoux/docker-terraform-graphviz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

terraform-graphviz docker image

Docker image to use terraform and graphviz to make it easier to generate graphs with terraform πŸ‘

Docker Stars Docker Pulls Docker Automated Docker Build Image Version Layers

Usage

Command line usage example

docker run --rm -it \
  --workdir=/app \
  -v "$PWD:/app" \
  -v "$HOME/.aws:/root/.aws/" \
  -v "$HOME/.ssh:/root/.ssh/" \
  gableroux/terraform-graphviz:light
    sh -c "terraform graph -draw-cycles | dot -Tsvg -o graph.svg"

docker-compose.yml example

version: '3'
services:
  # official terraform image
  terraform:
    image: hashicorp/terraform:light
    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:light
    env_file: .env
    volumes:
      - "$PWD:/app"
      - "$HOME/.aws:/root/.aws/"
      - "$HOME/.ssh:/root/.ssh/"

.gitlab-ci.yml example

This 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:light
  script:
    - cp .env.example .env
    - terraform init
    - terraform validate -check-variables=true # don't require aws credentials

FAQ

How to deploy new docker image

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. ✌️

Why bother using a docker image

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.

Why not use an official terraform image?

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.

My version is not there, what can I do?

Fork the project, replace version in FROM image and push your own image.

Can I contribute?

Yes, why not?

There are already a lot of terraform docker images out there, why a new one?

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.

How is this image deployed to docker hub?

I'm using docker's automated build

License

MIT Β© Gabriel Le Breton

About

🌏 Docker image to use terraform and graphviz to make it easier to generate graphs with terraform πŸ‘

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published