.pre-commit-config.yaml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. repos:
  2. - repo: https://github.com/antonbabenko/pre-commit-terraform
  3. rev: v1.74.1
  4. hooks:
  5. - id: terraform_docs
  6. always_run: true
  7. args:
  8. - --args=--sort-by-required
  9. - id: terraform_fmt
  10. - id: terraform_tflint
  11. alias: terraform_tflint_deep
  12. name: terraform_tflint_deep
  13. args:
  14. - --args=--deep
  15. - id: terraform_tflint
  16. alias: terraform_tflint_nocreds
  17. name: terraform_tflint_nocreds
  18. - id: terraform_tfsec
  19. #- id: terraform_checkov - Place holder until we are ready to implement fulltime
  20. - repo: local
  21. hooks:
  22. - id: terraform_validate
  23. name: terraform_validate
  24. entry: |
  25. bash -c '
  26. AWS_DEFAULT_REGION=us-east-1
  27. declare -a DIRS
  28. for FILE in "$@"
  29. do
  30. DIRS+=($(dirname "$FILE"))
  31. done
  32. for DIR in $(printf "%s\n" "${DIRS[@]}" | sort -u)
  33. do
  34. cd $(dirname "$FILE")
  35. terraform init --backend=false
  36. terraform validate .
  37. done
  38. '
  39. language: system
  40. verbose: true
  41. files: \.tf(vars)?$
  42. exclude: examples
  43. - repo: https://github.com/pre-commit/pre-commit-hooks
  44. rev: v4.3.0
  45. hooks:
  46. - id: check-case-conflict
  47. - id: check-json
  48. - id: check-merge-conflict
  49. - id: check-symlinks
  50. - id: check-yaml
  51. args:
  52. - --unsafe
  53. - id: end-of-file-fixer
  54. - id: mixed-line-ending
  55. args:
  56. - --fix=lf
  57. - id: no-commit-to-branch
  58. args:
  59. - --branch
  60. - main
  61. - --branch
  62. - master
  63. - --branch
  64. - prod
  65. - id: pretty-format-json
  66. args:
  67. - --autofix
  68. - --top-keys=name,Name
  69. - id: trailing-whitespace
  70. args:
  71. - --markdown-linebreak-ext=md
  72. exclude: README.md