.pre-commit-config.yaml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. repos:
  2. - repo: https://github.com/antonbabenko/pre-commit-terraform
  3. rev: v1.31.0
  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. - repo: local
  20. hooks:
  21. - id: terraform_validate
  22. name: terraform_validate
  23. entry: |
  24. bash -c '
  25. AWS_DEFAULT_REGION=us-east-1
  26. declare -a DIRS
  27. for FILE in "$@"
  28. do
  29. DIRS+=($(dirname "$FILE"))
  30. done
  31. for DIR in $(printf "%s\n" "${DIRS[@]}" | sort -u)
  32. do
  33. cd $(dirname "$FILE")
  34. terraform init --backend=false
  35. terraform validate .
  36. done
  37. '
  38. language: system
  39. verbose: true
  40. files: \.tf(vars)?$
  41. exclude: examples
  42. - repo: https://github.com/pre-commit/pre-commit-hooks
  43. rev: v3.0.0
  44. hooks:
  45. - id: check-case-conflict
  46. - id: check-json
  47. - id: check-merge-conflict
  48. - id: check-symlinks
  49. - id: check-yaml
  50. args:
  51. - --unsafe
  52. - id: end-of-file-fixer
  53. - id: mixed-line-ending
  54. args:
  55. - --fix=lf
  56. - id: no-commit-to-branch
  57. args:
  58. - --branch
  59. - main
  60. - --branch
  61. - master
  62. - --branch
  63. - prod
  64. - id: pretty-format-json
  65. args:
  66. - --autofix
  67. - --top-keys=name,Name
  68. - id: trailing-whitespace
  69. args:
  70. - --markdown-linebreak-ext=md
  71. exclude: README.md