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