-
Notifications
You must be signed in to change notification settings - Fork 27
/
.pre-commit-config.yaml
82 lines (76 loc) · 3.31 KB
/
.pre-commit-config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#
# requirements
# - install pre-commit (latest)
# - install terraform-docs (latest)
# - see .github/workflows/ci-pull-request.yaml for more info on what's being valiated on CI
# $ pre-commit run --color=always --show-diff-on-failure --all-files
#
repos:
# create a custom terraform validate for the examples, as launching the validation in the root dir won't work and give
# "Error: Provider configuration not present" error
# https://github.com/hashicorp/terraform/issues/21416
# https://discuss.hashicorp.com/t/how-to-run-terraform-validate-on-a-module-that-is-supplied-the-providers-via-an-alias/34664/2
# - repo: local
# hooks:
# - id: terraform_validate
# name: Terraform validate
# entry: resources/scripts/terraform_validate.sh
# pass_filenames: false
# language: script
# verbose: true
# https://github.com/antonbabenko/pre-commit-terraform/blob/master/README.md#terraform_validate (point 4)
- repo: local
hooks:
- id: terraform_clean
name: "Terraform Cleanup"
pass_filenames: false
language: system
entry: bash -c "find . \( -iname ".terraform*" ! -iname ".terraform-docs*" ! -path "*/test/*" \) -print0 | xargs -0 rm -r; true"
- repo: local
# Adding this patch to fix organizational multi-provider terraform validate error
# 'missing provider provider["registry.terraform.io/hashicorp/aws"].member'
# https://github.com/antonbabenko/pre-commit-terraform/#terraform_validate
hooks:
- id: generate_tf_providers
name: generate_tf_providers
language: system
entry: bash -c "./resources/scripts/generate_providers.sh ./modules/infrastructure/permissions/org-role-ecs ./examples/organizational"
pass_filenames: false
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.64.0
hooks:
- id: terraform_fmt
- id: terraform_docs
args:
- '--args=--sort-by required'
- id: terraform_tflint
exclude: (test)|(examples-internal)\/.*$
args:
- '--args=--only=terraform_comment_syntax'
- '--args=--only=terraform_deprecated_index'
- '--args=--only=terraform_deprecated_interpolation'
- '--args=--only=terraform_documented_outputs'
- '--args=--only=terraform_documented_variables'
- '--args=--only=terraform_module_pinned_source'
- '--args=--only=terraform_module_version'
- '--args=--only=terraform_naming_convention'
- '--args=--only=terraform_required_providers'
- '--args=--only=terraform_required_version'
- '--args=--only=terraform_standard_module_structure'
- '--args=--only=terraform_typed_variables'
- '--args=--only=terraform_unused_declarations'
- '--args=--only=terraform_unused_required_providers'
- '--args=--only=terraform_workspace_remote'
# https://github.com/antonbabenko/pre-commit-terraform#terraform_validate
- id: terraform_validate
exclude: (test)|(examples-internal)\/.*$
- id: terrascan
exclude: (test)
args:
- '--args=--skip-rules AC_AWS_0369'
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace