Skip to content

Instantly share code, notes, and snippets.

@Codesleuth
Last active September 7, 2021 10:20
Show Gist options
  • Save Codesleuth/9df928a6ec54a68eb029ed2ccabfb3cf to your computer and use it in GitHub Desktop.
Save Codesleuth/9df928a6ec54a68eb029ed2ccabfb3cf to your computer and use it in GitHub Desktop.
Terraform format using docker image

Given a structure like:

/
  /terraform
    /environment
    /infra
  /other

For x86/64 machines:

docker run -it --rm \
  -v $PWD:/data \
  -w /data/terraform \
  hashicorp/terraform:latest \
  fmt -diff -recursive

For M1 Apple Silicon Mac, specify the platform:

docker run -it --rm \
  --platform linux/amd64 \
  -v $PWD:/data \
  -w /data/terraform \
  hashicorp/terraform:latest \
  fmt -diff -recursive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment