diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 507d7e2ed..bc5c5882f 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -196,12 +196,19 @@ name: Terraform validate (Docker) description: >- Validates all Terraform configuration files using Docker. + Automatically runs 'terraform init' and retries validation if provider/module + errors are detected. NOTE: Requires Docker to be available. Use 'skip' in .pre-commit-config.yaml if running on pre-commit.ci or other environments without Docker. require_serial: true entry: ghcr.io/actuarysailor/pre-commit-terraform-tools:latest language: docker_image - args: [terraform, validate] + args: + - /usr/bin/hooks/terraform_validate.sh + - --hook-config=--retry-once-with-cleanup=true + - --hook-config=--parallelism-ci-cpu-cores=2 + - -- + - . pass_filenames: false files: \.(tf|tofu|tfvars|terraform\.lock\.hcl)$ exclude: \.terraform/.*$ diff --git a/examples/.pre-commit-config-docker.yaml b/examples/.pre-commit-config-docker.yaml index bbe1a4ba6..91294d672 100644 --- a/examples/.pre-commit-config-docker.yaml +++ b/examples/.pre-commit-config-docker.yaml @@ -3,9 +3,14 @@ # Skip Docker hooks on pre-commit.ci (which doesn't support Docker) ci: - skip: [terraform_fmt_docker, terraform_validate_docker, terraform_tflint_docker, - terraform_docs_docker, terraform_checkov_docker, terraform_trivy_docker, - infracost_breakdown_docker] + skip: + - terraform_fmt_docker + - terraform_validate_docker + - terraform_tflint_docker + - terraform_docs_docker + - terraform_checkov_docker + - terraform_trivy_docker + - infracost_breakdown_docker repos: - repo: https://github.com/actuarysailor/pre-commit-terraform