devopsinfra/docker-terragrunt

Sponsored OSS

By DevOps Infra

Updated 1 day ago

Dockerized framework with Terraform, Terragrunt, Python, Make, Docker, Git, and all needed component

Image
Security
Integration & delivery
11

1M+

devopsinfra/docker-terragrunt repository overview

Dockerized IaC framework for Terraform, OpenTofu and Terragrunt

Supporting amd64 and arm64 images!
Due to excessive size of the images and upcoming Docker Hub limits, I'm are currently working on reducing it. Please use the latest versions of the images to keep up with the most active versions. Images older than 3 month will be deleted.

Sources and Docker images

Source code at devops-infra/docker-terragrunt.

Docker Hub images at docker.io/devopsinfra/docker-terragrunt

GitHub Packages images at ghcr.io/devops-infra/docker-terragrunt/docker-terragrunt

Info

Alpine-based Docker image with Terraform or OpenTofu, together with Terragrunt, Go, Python, Make, Docker, Git, and all needed components to easily manage cloud infrastructure for CI/CD environments as a runner image.

Including cloud CLIs and SDKs for Amazon Web Services, Microsoft Azure, Google Cloud Platform.

Azure-enabled flavors are built on top of devops-infra/docker-azure-cli to reduce Azure CLI install time during image builds.

Best used as runner image for CI/CD in automation, as well as a consistent local run environment.

Please note focus of those images is to maintain availability of current versions of Terraform, OpenTofu and Terragrunt, not CLIs or other dependencies. Hence, images are updated when new version of Terraform, OpenTofu or Terragrunt is released. Furthermore, versioning labels of images contain versions of said software to emphasize it.

Dockerfile was based on two images made by cytopia: docker-terragrunt and docker-terragrunt-fmt . Original README files are included in this repository: docker-terragrunt and docker-terragrunt-fmt . This project grew much bigger than the original ones and is intended to be a framework for cloud Infrastructure-as-a-Code.

All Contributors

Gitmoji

GitHub GitHub last commit

DockerHub Docker Pulls

Available source images

Tag of the image tells which version of Terraform and Terragrunt it contains and which public cloud provider CLI it's bundled with or not (see second table below).

Current release full tag version value
tf-1.15.8-ot-1.12.4-tg-1.1.0
RegistryExample full image nameImage nameImage versionTerraform versionOpenTofu versionTerragrunt version
Docker Hubdevopsinfra/docker-terragrunt:tf-1.15.8-tg-1.1.0docker-terragrunttf-1.15.8-tg-1.1.01.15.8N/A1.1.0
Docker Hubdevopsinfra/docker-terragrunt:ot-1.12.4-tg-1.1.0docker-terragruntot-1.12.4-tg-1.1.0N/A1.12.41.1.0
GitHub Packagesghcr.io/devops-infra/docker-terragrunt/docker-terragrunt:tf-1.15.8-tg-1.1.0docker-terragrunttf-1.15.8-tg-1.1.01.15.8N/A1.1.0
GitHub Packagesghcr.io/devops-infra/docker-terragrunt/docker-terragrunt:ot-1.12.4-tg-1.1.0docker-terragruntot-1.12.4-tg-1.1.0N/A1.12.41.1.0

Available flavors

Tag of the image tells also which cloud API/SDK is included in the image.

Image nameAWSAzureGCPOTTFDescription
docker-terragrunt:slim-tf-latestLightweight version with TF, TG and bare dependencies.
Docker size
docker-terragrunt:slim-ot-latestLightweight version with OT, TG and bare dependencies.
Docker size
docker-terragrunt:tf-latestNormal version, with TF. Having Go, Python, Make, etc.
Docker size
docker-terragrunt:ot-latestNormal version, with OT. Having Go, Python, Make, etc.
Docker size
docker-terragrunt:aws-tf-latestNormal version with AWS CLI, with TF.
Docker size
docker-terragrunt:aws-ot-latestNormal version with AWS CLI, with OT.
Docker size
docker-terragrunt:azure-tf-latestNormal version with Azure CLI, with TF.
Docker size
docker-terragrunt:azure-ot-latestNormal version with Azure CLI, with OT.
Docker size
docker-terragrunt:aws-azure-tf-latestNormal version with AWS and Azure CLIs, with TF.
Docker size
docker-terragrunt:aws-azure-ot-latestNormal version with AWS and Azure CLIs, with OT.
Docker size
docker-terragrunt:gcp-tf-latestNormal version with GCP CLI, with TF.
Docker size
docker-terragrunt:gcp-ot-latestNormal version with GCP CLI, with OT.
Docker size
docker-terragrunt:aws-gcp-tf-latestNormal version with AWS and GCP CLIs, with TF.
Docker size
docker-terragrunt:aws-gcp-ot-latestNormal version with AWS and GCP CLIs, with OT.
Docker size
docker-terragrunt:azure-gcp-tf-latestNormal version with Azure and GCP CLIs, with TF.
Docker size
docker-terragrunt:azure-gcp-ot-latestNormal version with Azure and GCP CLIs, with OT.
Docker size
docker-terragrunt:aws-azure-gcp-tf-latestNormal version with AWS, Azure and GCP CLIs, with TF.
Docker size
docker-terragrunt:aws-azure-gcp-ot-latestNormal version with AWS, Azure and GCP CLIs, with OT.
Docker size

Test coverage matrix

Container-structure-tests validate both positive and negative cases for installed software. For each flavor, tests run against both image variants (-tf-... and -ot-...).

FlavorExpected cloud CLIs presentExpected cloud CLIs absentExtra constraints checked
slimnoneaws, az, gcloudcurl, git, jq, vim, wget, unzip
plainnoneaws, az, gcloudslim flavor + task, make, docker, go, python3, tflint, hcledit, sops, etc.
awsawsaz, gcloudplain flavor + boto3
azureazaws, gcloudplain flavor
gcpgcloudaws, azplain flavor
aws-azureaws, azgcloudplain flavor
aws-gcpaws, gcloudazplain flavor
azure-gcpaz, gcloudawsplain flavor
aws-azure-gcpaws, az, gcloudnoneplain flavor

Additionally, tool-variant tests verify:

  • TF image contains the exact Terraform version and does not contain OpenTofu.
  • OT image contains the exact OpenTofu version and does not contain Terraform.
  • Both variants validate exact Terragrunt and flavor-specific tool versions sourced from Dockerfile ARG values.

Usage

  • For working with local files - mount working directory under /data, e.g. --volume $(pwd):/data.
  • For working with cloud providers - pass their credentials as additional file or environment variables, e.g. --env AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN} or --volume ~/.aws/credentials:/root/.aws/credentials.
  • For running other Docker images - by sharing the socket, e.g. --privileged --volume /var/run/docker.sock:/var/run/docker.sock.
  • For configuring git - mount desired .gitconfig and/or SSH key (if needed), e.g. --volume ~/.gitconfig:/root/.gitconfig --volume ~/.ssh/id_rsa_github:/root/.ssh/id_rsa
Examples of .gitconfig to mount
  • Use https with Personal Access Token:
[url "https://{GITHUB_TOKEN}@github.com/"]
	insteadOf = https://github.com/
[url "https://{GITHUB_TOKEN}@github.com/"]
	insteadOf = git+ssh://github.com/
[url "https://{GITHUB_TOKEN}@github.com/"]
	insteadOf = [email protected]:
  • Use https instead of git/ssh:
[url "https://github.com/"]
	insteadOf = git+ssh://github.com/
[url "https://github.com/"]
	insteadOf = [email protected]:
  • Use ssh instead of https:
[url "ssh://[email protected]/"]
  insteadOf = https://github.com/
[url "ssh://[email protected]/"]
	insteadOf = [email protected]:

Examples

  • Format all HCL files in the current directory. Including subdirectories.
docker run --rm \
    --user $(id -u):$(id -g) \
    --volume $(pwd):/data \
    devopsinfra/docker-terragrunt:latest format-hcl
  • Plan terraform deployment in AWS for files in current directory.
docker run --rm \
    --tty --interactive \
    --env AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} \
    --env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
    --env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
    --env AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN} \
    --user $(id -u):$(id -g) \
    --volume $(pwd):/data \
    devopsinfra/docker-terragrunt:aws-latest terraform plan
  • Apply terragrunt deployment in subdirectory. With GitHub using a ~/.gitconfig file with PAT.
docker run --rm \
    --tty --interactive \
    --user $(id -u):$(id -g) \
    --volume $(pwd):/data \
    --volume ~/.gitconfig:/root/.gitconfig \
    devopsinfra/docker-terragrunt:aws-latest terragrunt apply --terragrunt-working-dir some/module
  • Run a Makefile target as orchestration script.
docker run --rm \
    --tty --interactive \
    --user $(id -u):$(id -g) \
    --volume $(pwd):/data \
    devopsinfra/docker-terragrunt:latest make build

Additional software available in all images

Scripts
Script nameIs included in PATHPurposeSource/Documentation
format-hclYesFor formatting all HCL files (.hcl, .tf and .tfvars) into format suggested by Hashicorp.devops-infra
terragrunt-fmt.shNoDependency for format-hclcytopia
entrypoint.shYesMain CMD target for Docker image, just to show main installed binaries versions.devops-infra
Binaries and Python libraries
NameTypeFlavorDescriptionSource/Documentation
awscliBinaryawsInteract with AWS via terminal.https://github.com/aws/aws-cli
azure-cliBinaryazureInteract with Azure via terminal.https://github.com/Azure/azure-cli
bcBinarynon-slimNumeric operations.https://www.gnu.org/software/bc/bc.html
boto3Python libraryawsInteract with AWS via Python.https://github.com/boto/boto3
cloudflarePython librarynon-slimCloudflare API operations.https://github.com/cloudflare/python-cloudflare
curlBinaryslimHTTP and API calls.https://curl.haxx.se/
dockerBinarynon-slimRun nested Docker workloads (for example, Lambda packaging workflows).https://github.com/docker/docker-ce
gitBinaryslimInteract with Git repositories.https://git-scm.com/
goBinarynon-slimBuild/install additional Go tooling.https://go.dev/
google-cloud-cliBinarygcpInteract with GCP via terminal.https://cloud.google.com/sdk
gnupgBinarynon-slimGPG operations (including AWS CLI signature verification).https://gnupg.org/
graphvizBinarynon-slimGenerate graph output, for example from terraform graph.https://graphviz.org/
hcleditBinarynon-slimRead/write HCL files.https://github.com/minamijoyo/hcledit
ghBinarynon-slimInteract with GitHub via official GitHub CLI.https://cli.github.com/
jqBinaryslimParse JSON outputs.https://stedolan.github.io/jq/
makeBinarynon-slimMakefile-based task orchestration.https://www.gnu.org/software/make/
ncurses (tput)Binarynon-slimColor and terminal helpers used by automation scripts.https://invisible-island.net/ncurses/announce.html
openssh-client (ssh)Binarynon-slimOutbound SSH connections.https://www.openssh.com/
opensslBinarynon-slimCryptographic operations and hashing.https://github.com/openssl/openssl
opentofuBinaryslimOpen-source Terraform alternative for IaC.https://github.com/opentofu/opentofu
PyGithubPython librarynon-slimInteract with GitHub API in Python.https://github.com/PyGithub/PyGithub
python-hcl2Python librarynon-slimParse HCL in Python.https://github.com/amplify-education/python-hcl2
python3Binarynon-slimExecute Python scripts in automation workflows.https://www.python.org/
python (python)Binarynon-slimpython command alias to Python 3.https://www.python.org/
python3-pip (pip3, pip)Binarynon-slimPython package management.https://pip.pypa.io/
requestsPython librarynon-slimHTTP requests from Python.https://github.com/psf/requests
slack_sdkPython librarynon-slimSlack integration in Python.https://github.com/slackapi/python-slack-sdk
sopsBinarynon-slimEncrypt/decrypt secrets used by Terragrunt workflows.https://github.com/getsops/sops
taskBinarynon-slimTaskfile-based task orchestrationhttps://taskfile.dev/
terraformBinaryslimIaC engine used directly and by Terragrunt.https://github.com/hashicorp/terraform
terragruntBinaryslimIaC wrapper over Terraform/OpenTofu.https://github.com/gruntwork-io/terragrunt
tflintBinarynon-slimTerraform/OpenTofu linting.https://github.com/terraform-linters/tflint
unzipBinaryslimExtract archives during workflows.http://infozip.sourceforge.net/
vimBinaryslimBasic editor in container shell sessions.https://www.vim.org/
wgetBinaryslimDownload helper utility.https://www.gnu.org/software/wget/
zipBinarynon-slim

Tag summary

Content type

Image

Digest

sha256:ab39015b2

Size

655.4 MB

Last updated

1 day ago

docker pull devopsinfra/docker-terragrunt:aws-azure-gcp-ot-latest

This week's pulls

Pulls:

16,334

Last week