A lightweight Terraform Docker image based on Alpine Linux
10K+
A Terraform Docker image:
multiarch with support of amd64 and arm64,Terraform, packages and state2inventory),SBOM) attestation added using Syft,Terraform is no longer pinned to the fixed 1.5.* series; it now tracks the official upstream releases.
This image also includes a Python program state2inventory to generate an Ansible inventory from an infrastructure state.
docker run -t --rm jfxs/terraform-inventory terraform version
docker run -t --rm jfxs/terraform-inventory state2inventory terraform --help
or
docker run -t --rm quay.io/ifxs/terraform-inventory terraform version
docker run -t --rm quay.io/ifxs/terraform-inventory state2inventory terraform --help
To generate an Ansible inventory from a Terraform state, mount your working directory (the container user is non-root and
may have an arbitrary uid, so pass yours with the group 0):
terraform show -json > state.json
docker run --rm --user "$(id -u):0" -v "$PWD":/work -w /work jfxs/terraform-inventory \
state2inventory terraform -s state.json -o inventory.ini
HOME is /tmp: it's writable whatever the uid, but it doesn't persist between runs.
Docker latest tag is 1.16.5-001, 1.16, 1.
The complete software bill of materials (SBOM) of each published image, with its known vulnerabilities,
is collected in the sbom-docker repository, under the
component docker-terraform-inventory.
Dockerhub Overview page has the details of the last published image.
Docker tag definition:
<terraform_version>-<increment>
Example: 1.16.4-003
Each publication also moves the tags <major>.<minor> (for example 1.16), <major> (for example 1) and latest.
Requirements: Docker and Task. The task templates in Taskfile.d/ aren't versioned:
download them first.
task install-templates # download the task templates (Taskfile.d/)
task 00:10-build-local # build the image, terraform version read from the Dockerfile (ARG VERSION)
task 00:40-test-local # versions and tests/test-image.sh, as the default user and as an arbitrary uid
task 00:999-pre-commit # all the linters
Every dependency of the Dockerfile is pinned and kept up to date by Renovate (see renovate.json). The apk pins follow the
Alpine branch of the base image tag: when this tag moves to a newer Alpine, update the alpine-main and alpine-community
URLs in renovate.json and every apk pin together.
The pipeline uses the op_so GitLab CI components (lint, renovate, docker). Variables
to set in the project settings (protected, and masked when possible):
| Variable | Usage |
|---|---|
DOCKERHUB_USER, DOCKERHUB_PASSWORD | Publication on Docker Hub |
QUAY_USER, QUAY_PASSWORD, APIKEY__QUAY_IO | Publication on Quay.io and of the README |
COSIGN_PRIVATE_KEY, COSIGN_PASSWORD, COSIGN_PUBLIC_KEY | Image signature and SBOM attestation (the default branch must be protected) |
BOMPAGE_TOKEN, BOMPAGE_SIGN_KEY | Publication of the SBOM to sbom-docker |
RENOVATE_TOKEN, GITHUB_COM_TOKEN | Renovate (the second one is optional) |
Renovate runs from a scheduled pipeline with the variable RENOVATE=true; set DISABLE_JOBS=true on this schedule so that no
other job runs.
Cosign public key:
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEa3yV6+yd/l4zh/tfT6Tx+zn0dhy3
BhFqSad1norLeKSCN2MILv4fZ9GA6ODOlJOw+7vzUvzZVr9IXnxEdjoWJw==
-----END PUBLIC KEY-----
The public key is also available online: https://gitlab.com/op_so/docker/cosign-public-key/-/raw/main/cosign.pub.
To verify an image:
cosign verify --key cosign.pub $IMAGE_URI
To verify and get the software bill of materials (SBOM) attestation:
cosign verify-attestation --key cosign.pub --type spdxjson $IMAGE_URI | jq '.payload | @base64d | fromjson | .predicate'
This program is free software: you can redistribute it and/or modify it under the terms of the MIT License (MIT). See the LICENSE for details.
Content type
Image
Digest
sha256:9e9fa8b8b…
Size
76.3 MB
Last updated
8 days ago
docker pull jfxs/terraform-inventory