Skip to content

Commit faa3662

Browse files
committed
Initialize Athena module with base template structure
0 parents  commit faa3662

25 files changed

+720
-0
lines changed

.editorconfig

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
# Uses editorconfig to maintain consistent coding styles
3+
4+
# top-most EditorConfig file
5+
root = true
6+
7+
# Unix-style newlines with a newline ending every file
8+
[*]
9+
charset = utf-8
10+
end_of_line = lf
11+
indent_size = 2
12+
indent_style = space
13+
insert_final_newline = true
14+
max_line_length = 80
15+
trim_trailing_whitespace = true
16+
17+
[*.{tf,tfvars}]
18+
indent_size = 2
19+
indent_style = space
20+
21+
[*.md]
22+
max_line_length = 0
23+
trim_trailing_whitespace = false
24+
25+
[Makefile]
26+
tab_width = 2
27+
indent_style = tab
28+
29+
[COMMIT_EDITMSG]
30+
max_line_length = 0

.github/workflows/pr-title.yaml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 'Validate PR title'
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
main:
8+
name: Validate PR title
9+
runs-on: ubuntu-latest
10+
steps:
11+
# Please look up the latest version from
12+
# https://github.com/amannn/action-semantic-pull-request/releases
13+
- uses: amannn/[email protected]
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
with:
17+
# Configure which types are allowed.
18+
# Default: https://github.com/commitizen/conventional-commit-types
19+
types: |
20+
fix
21+
feat
22+
docs
23+
ci
24+
chore
25+
# Configure that a scope must always be provided.
26+
requireScope: false
27+
# Configure additional validation for the subject based on a regex.
28+
# This example ensures the subject starts with an uppercase character.
29+
subjectPattern: ^[A-Z].+$
30+
# If `subjectPattern` is configured, you can use this property to override
31+
# the default error message that is shown when the pattern doesn't match.
32+
# The variables `subject` and `title` can be used within the message.
33+
subjectPatternError: |
34+
The subject "{subject}" found in the pull request title "{title}"
35+
didn't match the configured pattern. Please ensure that the subject
36+
starts with an uppercase character.
37+
# For work-in-progress PRs you can typically use draft pull requests
38+
# from Github. However, private repositories on the free plan don't have
39+
# this option and therefore this action allows you to opt-in to using the
40+
# special "[WIP]" prefix to indicate this state. This will avoid the
41+
# validation of the PR title and the pull request checks remain pending.
42+
# Note that a second check will be reported if this is enabled.
43+
wip: true
44+
# When using "Squash and merge" on a PR with only one commit, GitHub
45+
# will suggest using that commit message instead of the PR title for the
46+
# merge commit, and it's easy to commit this by mistake. Enable this option
47+
# to also validate the commit message for one commit PRs.
48+
validateSingleCommit: false

.github/workflows/release.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: 'Module Release'
2+
3+
on:
4+
workflow_call:
5+
6+
defaults:
7+
run:
8+
shell: bash
9+
10+
jobs:
11+
release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Git pull
19+
run: git pull origin main
20+
21+
- name: Release
22+
uses: cycjimmy/semantic-release-action@v2
23+
with:
24+
semantic_version: 18.0.0
25+
extra_plugins: |
26+
@semantic-release/[email protected]
27+
@semantic-release/[email protected]
28+
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Terraform Checks
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
TERRAFORM_DOCS_VERSION: v0.18.0
8+
TFLINT_VERSION: v0.52.0
9+
10+
jobs:
11+
test:
12+
name: Test
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Setup Terraform
16+
uses: hashicorp/setup-terraform@v3
17+
with:
18+
terraform_version: "1.8.4"
19+
20+
- name: Initialize Terraform
21+
id: init
22+
run: terraform init -input=false
23+
24+
- name: Terraform Test
25+
id: fmt
26+
run: terraform test
27+
28+
collectInputs:
29+
name: Collect workflow inputs
30+
needs: test
31+
runs-on: ubuntu-latest
32+
outputs:
33+
directories: ${{ steps.dirs.outputs.directories }}
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Get root directories
39+
id: dirs
40+
uses: clowdhaus/terraform-composite-actions/[email protected]
41+
42+
preCommitMinVersions:
43+
name: Min TF pre-commit
44+
needs: collectInputs
45+
runs-on: ubuntu-latest
46+
strategy:
47+
matrix:
48+
directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}
49+
steps:
50+
# https://github.com/orgs/community/discussions/25678#discussioncomment-5242449
51+
- name: Delete huge unnecessary tools folder
52+
run: |
53+
rm -rf /opt/hostedtoolcache/CodeQL
54+
rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk
55+
rm -rf /opt/hostedtoolcache/Ruby
56+
rm -rf /opt/hostedtoolcache/go
57+
58+
- name: Checkout
59+
uses: actions/checkout@v4
60+
61+
- name: Terraform min/max versions
62+
id: minMax
63+
uses: clowdhaus/[email protected]
64+
with:
65+
directory: ${{ matrix.directory }}
66+
67+
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
68+
# Run only validate pre-commit check on min version supported
69+
if: ${{ matrix.directory != '.' }}
70+
uses: clowdhaus/terraform-composite-actions/[email protected]
71+
with:
72+
terraform-version: ${{ steps.minMax.outputs.minVersion }}
73+
tflint-version: ${{ env.TFLINT_VERSION }}
74+
args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'
75+
76+
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
77+
# Run only validate pre-commit check on min version supported
78+
if: ${{ matrix.directory == '.' }}
79+
uses: clowdhaus/terraform-composite-actions/[email protected]
80+
with:
81+
terraform-version: ${{ steps.minMax.outputs.minVersion }}
82+
tflint-version: ${{ env.TFLINT_VERSION }}
83+
args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)'
84+
85+
preCommitMaxVersion:
86+
name: Max TF pre-commit
87+
runs-on: ubuntu-latest
88+
needs: collectInputs
89+
steps:
90+
# https://github.com/orgs/community/discussions/25678#discussioncomment-5242449
91+
- name: Delete huge unnecessary tools folder
92+
run: |
93+
rm -rf /opt/hostedtoolcache/CodeQL
94+
rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk
95+
rm -rf /opt/hostedtoolcache/Ruby
96+
rm -rf /opt/hostedtoolcache/go
97+
98+
- name: Checkout
99+
uses: actions/checkout@v4
100+
with:
101+
ref: ${{ github.event.pull_request.head.ref }}
102+
repository: ${{github.event.pull_request.head.repo.full_name}}
103+
104+
- name: Terraform min/max versions
105+
id: minMax
106+
uses: clowdhaus/[email protected]
107+
108+
- name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}
109+
uses: clowdhaus/terraform-composite-actions/[email protected]
110+
with:
111+
terraform-version: ${{ steps.minMax.outputs.maxVersion }}
112+
tflint-version: ${{ env.TFLINT_VERSION }}
113+
terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}
114+
install-hcledit: true

.github/workflows/terraform-docs.yaml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Terraform Docs
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
TERRAFORM_DOCS_VERSION: v0.18.0
8+
9+
jobs:
10+
generateDocs:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.ref }}
17+
18+
- name: Render and Push terraform docs for main module
19+
uses: terraform-docs/gh-actions@main
20+
with:
21+
working-dir: .
22+
git-push: true
23+
output-file: README.md
24+
output-format: markdown table
25+
output-method: replace
26+
recursive: false
27+
template: |
28+
<!-- BEGIN_TF_DOCS -->
29+
{{ .Content }}
30+
<!-- END_TF_DOCS -->
31+
{{- printf "\n" -}}
32+
args: "--header-from .header.md"
33+
34+
- name: Check if modules folder exists
35+
id: check_modules
36+
run: echo "modules_exists=$(if [ -d modules ]; then echo true; else echo false; fi)" >> $GITHUB_ENV
37+
38+
- name: Render and Push terraform docs for sub modules
39+
if: env.modules_exists == 'true'
40+
uses: terraform-docs/gh-actions@main
41+
with:
42+
working-dir: .
43+
git-push: true
44+
output-file: README.md
45+
output-format: markdown table
46+
output-method: replace
47+
recursive: true
48+
recursive-path: modules
49+
template: |
50+
<!-- BEGIN_TF_DOCS -->
51+
{{ .Content }}
52+
<!-- END_TF_DOCS -->
53+
{{- printf "\n" -}}
54+
args: "--header-from .header.md"
55+
56+
57+
- name: Check if examples folder exists
58+
id: check_examples
59+
run: echo "examples_exists=$(if [ -d examples ]; then echo true; else echo false; fi)" >> $GITHUB_ENV
60+
61+
- name: Render and Push terraform docs for examples
62+
if: env.examples_exists == 'true'
63+
uses: terraform-docs/gh-actions@main
64+
with:
65+
working-dir: .
66+
git-push: true
67+
output-file: README.md
68+
output-format: markdown table
69+
output-method: replace
70+
recursive: true
71+
recursive-path: examples
72+
template: |
73+
<!-- BEGIN_TF_DOCS -->
74+
{{ .Content }}
75+
<!-- END_TF_DOCS -->
76+
{{- printf "\n" -}}
77+
args: "--header-from .header.md"

.github/workflows/terraform.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Terraform Master Workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request_target:
9+
types:
10+
- opened
11+
- edited
12+
- synchronize
13+
pull_request:
14+
branches:
15+
- main
16+
- master
17+
jobs:
18+
prTitlecheck:
19+
name: PR title check
20+
if: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.base.ref == 'main' }}
21+
uses: ./.github/workflows/pr-title.yaml
22+
23+
preCommitCheck:
24+
name: Terraform Checks
25+
uses: ./.github/workflows/terraform-checks.yaml
26+
27+
generateDocs:
28+
name: Generate Terraform Docs
29+
needs: preCommitCheck
30+
uses: ./.github/workflows/terraform-docs.yaml
31+
32+
release:
33+
name: Release module
34+
needs: generateDocs
35+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
36+
uses: ./.github/workflows/release.yaml

.github/workflows/update-configs.yaml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Update Configuration from Template
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
update:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout template repository
12+
uses: actions/checkout@v3
13+
with:
14+
repository: infraspecdev/terraform-module-template
15+
token: ${{ secrets.GITHUB_TOKEN }}
16+
path: template-repo
17+
18+
- name: Checkout target repository
19+
uses: actions/checkout@v3
20+
with:
21+
repository: ${{ github.repository }}
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
path: target-repo
24+
25+
- name: Set up Git
26+
run: |
27+
git config --global user.name "github-actions"
28+
git config --global user.email "[email protected]"
29+
30+
- name: Copy files from template repository
31+
run: |
32+
cp template-repo/.editorconfig target-repo/
33+
cp template-repo/.pre-commit-config.yaml target-repo/
34+
cp template-repo/LICENSE target-repo/
35+
cp template-repo/.tflint.hcl target-repo/
36+
cp template-repo/.releaserc.json target-repo/
37+
cp template-repo/CODE_OF_CONDUCT.md target-repo/
38+
cp template-repo/CONTRIBUTING.md target-repo/
39+
40+
- name: Commit and push changes
41+
run: |
42+
cd target-repo
43+
git add .
44+
git commit -m "Update files from terraform-module-template"
45+
git push

0 commit comments

Comments
 (0)