Skip to content

Commit ae1b4f9

Browse files
authored
Initial commit
0 parents  commit ae1b4f9

File tree

17 files changed

+666
-0
lines changed

17 files changed

+666
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Copyright 2025 Cloudera, Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Check Terraform module documentation
16+
17+
on:
18+
pull_request:
19+
push:
20+
branches: [main]
21+
22+
env:
23+
TERRAFORM_DOCS_VERSION: v0.20.0
24+
25+
jobs:
26+
check-tf-fmt:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v3
31+
32+
- name: Find the modules
33+
id: find_modules
34+
run: |
35+
echo "MODULES=$(find modules/ -maxdepth 1 -type d -name 'terraform-*' | paste -sd,)" >> "$GITHUB_ENV"
36+
37+
- name: Print list of modules
38+
run: |
39+
echo "Terraform modules found: $MODULES"
40+
41+
- name: Install the terraform-docs utility
42+
run: |
43+
curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/${TERRAFORM_DOCS_VERSION}/terraform-docs-${TERRAFORM_DOCS_VERSION}-linux-amd64.tar.gz
44+
tar -xzf terraform-docs.tar.gz
45+
chmod +x terraform-docs
46+
sudo mv terraform-docs /usr/local/bin/
47+
48+
- name: Validate terraform module docs with terraform-docs
49+
run: |
50+
FAILED_MODULES=()
51+
for module in $(echo "$MODULES" | tr ',' '\n'); do
52+
echo "Checking $module"
53+
if ! terraform-docs --output-check "$module"; then
54+
echo "❌ terraform-docs check failed for $module"
55+
FAILED_MODULES+=("$module")
56+
else
57+
echo "✅ $module passed terraform-docs check"
58+
fi
59+
done
60+
61+
if [ ${#FAILED_MODULES[@]} -ne 0 ]; then
62+
echo "The following modules failed terraform-docs check:"
63+
for failed in "${FAILED_MODULES[@]}"; do
64+
echo " - $failed"
65+
done
66+
exit 1
67+
fi
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2023 Cloudera, Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Check Terraform Formatting
16+
17+
on:
18+
pull_request:
19+
push:
20+
branches: [main]
21+
22+
jobs:
23+
check-tf-fmt:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
29+
# Setup terraform
30+
- name: Setup Terraform
31+
uses: hashicorp/setup-terraform@v3
32+
33+
- name: Validate with terraform fmt
34+
uses: pre-commit/[email protected]
35+
with:
36+
extra_args: terraform_fmt --all-files
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2023 Cloudera, Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Validate Configuration with terraform validate
16+
17+
on:
18+
pull_request:
19+
push:
20+
branches: [main]
21+
22+
jobs:
23+
check-tf-validate:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
29+
# Setup terraform
30+
- name: Setup Terraform
31+
uses: hashicorp/setup-terraform@v3
32+
33+
- name: Validate with terraform validate
34+
uses: pre-commit/[email protected]
35+
with:
36+
extra_args: terraform_validate --all-files

.github/workflows/check_tflint.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2023 Cloudera, Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Run Terraform Lint
16+
17+
on:
18+
pull_request:
19+
push:
20+
branches: [main]
21+
22+
jobs:
23+
check-tf-lint:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
29+
# Setup terraform
30+
- name: Setup Terraform
31+
uses: hashicorp/setup-terraform@v3
32+
33+
- name: Install the tflint utility
34+
run: |
35+
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
36+
37+
- name: Validate with tflint
38+
uses: pre-commit/[email protected]
39+
with:
40+
extra_args: terraform_tflint --all-files

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Local .terraform directories and lock files
2+
**/.terraform/*
3+
**/.terraform.lock.hcl
4+
5+
# .tfstate files
6+
*.tfstate
7+
*.tfstate.*
8+
9+
# Crash log files
10+
crash.log
11+
crash.*.log
12+
13+
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
14+
# password, private keys, and other secrets. These should not be part of version
15+
# control as they are data points which are potentially sensitive and subject
16+
# to change depending on the environment.
17+
*.tfvars
18+
*.tfvars.json
19+
20+
# Ignore override files as they are usually used to override resources locally and so
21+
# are not checked in
22+
override.tf
23+
override.tf.json
24+
*_override.tf
25+
*_override.tf.json
26+
27+
# Include override files you do wish to add to version control using negated pattern
28+
# !example_override.tf
29+
30+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
31+
# example: *tfplan*
32+
33+
# Ignore CLI configuration files
34+
.terraformrc
35+
terraform.rc

.pre-commit-config.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright 2023 Cloudera, Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
repos:
16+
- repo: https://github.com/antonbabenko/pre-commit-terraform
17+
rev: v1.77.3
18+
hooks:
19+
# see https://github.com/antonbabenko/pre-commit-terraform#terraform_fmt
20+
- id: terraform_fmt
21+
args:
22+
- --args=-diff
23+
24+
# see https://github.com/antonbabenko/pre-commit-terraform#terraform_validate
25+
- id: terraform_validate
26+
exclude: examples/.*
27+
28+
# see https://github.com/antonbabenko/pre-commit-terraform#terraform_providers_lock
29+
- id: terraform_providers_lock
30+
31+
# see https://github.com/antonbabenko/pre-commit-terraform#terraform_tflint
32+
- id: terraform_tflint
33+
exclude: 'examples/.*'
34+
args:
35+
- '--args=--only=terraform_deprecated_interpolation'
36+
- '--args=--only=terraform_deprecated_index'
37+
- '--args=--only=terraform_unused_declarations'
38+
- '--args=--only=terraform_comment_syntax'
39+
- '--args=--only=terraform_documented_outputs'
40+
- '--args=--only=terraform_documented_variables'
41+
- '--args=--only=terraform_typed_variables'
42+
- '--args=--only=terraform_module_pinned_source'
43+
- '--args=--only=terraform_naming_convention'
44+
- '--args=--only=terraform_required_version'
45+
- '--args=--only=terraform_required_providers'
46+
- '--args=--only=terraform_standard_module_structure'
47+
- '--args=--only=terraform_workspace_remote'

0 commit comments

Comments
 (0)