diff --git a/.github/commitlint.config.js b/.github/commitlint.config.js new file mode 100644 index 0000000..c50801f --- /dev/null +++ b/.github/commitlint.config.js @@ -0,0 +1,13 @@ +const Configuration = { + + extends: ['@commitlint/config-conventional'], + + /* + * Any rules defined here will override rules from @commitlint/config-conventional + */ + rules: { + 'body-max-line-length': [2, 'always', 200], + }, +}; + +module.exports = Configuration; diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d1f94de --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +version: 2 +updates: + - package-ecosystem: terraform + directory: "/" + schedule: + interval: "daily" + open-pull-requests-limit: 10 + + - package-ecosystem: terraform + directory: "/examples" + schedule: + interval: "daily" + open-pull-requests-limit: 10 + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + open-pull-requests-limit: 10 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..8da8a0c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,28 @@ +name: Build + +on: [ push, workflow_dispatch ] + +jobs: + examples: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] + tf-version: [ 1.1.9, 1.2.9, 1.3.2 ] + steps: + - name: Install terraform v${{ matrix.tf-version }} + run: | + curl -LO https://releases.hashicorp.com/terraform/${{ matrix.tf-version }}/terraform_${{ matrix.tf-version }}_linux_amd64.zip + unzip terraform_${{ matrix.tf-version }}_linux_amd64.zip + sudo mv terraform /usr/local/bin + rm * + - name: Checkout code + uses: actions/checkout@v2 + - name: Validate examples terraform v${{ matrix.tf-version }} + run: make examples + build: + needs: [examples] + runs-on: ubuntu-latest + steps: + - run: echo "OK" diff --git a/.github/workflows/commitlint.yaml b/.github/workflows/commitlint.yaml new file mode 100644 index 0000000..bb8ad8c --- /dev/null +++ b/.github/workflows/commitlint.yaml @@ -0,0 +1,14 @@ +name: Lint Commit Messages + +on: [pull_request] + +jobs: + commitlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: wagoid/commitlint-github-action@v5 + with: + configFile: "./.github/commitlint.config.js" diff --git a/.github/workflows/terrascan.yaml b/.github/workflows/terrascan.yaml new file mode 100644 index 0000000..bf97d17 --- /dev/null +++ b/.github/workflows/terrascan.yaml @@ -0,0 +1,30 @@ +name: Terrascan +on: [ pull_request ] +# https://github.com/marketplace/actions/terrascan-iac-scanner +jobs: + terrascan: + runs-on: ubuntu-latest + name: terrascan + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Run Terrascan + id: terrascan + uses: tenable/terrascan-action@main + with: + iac_type: 'terraform' + iac_version: 'v14' + policy_type: 'aws' + only_warn: true + sarif_upload: true + #non_recursive: + #iac_dir: + #policy_path: + #skip_rules: + #config_path: + #webhook_url: + #webhook_token: + - name: Upload SARIF file + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: terrascan.sarif diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5105f48 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# Local .terraform directories +**/.terraform/* + +# .tfstate files +#*.tfstate +*.tfstate.* + +# Crash log files +crash.log +*.tfvars + + +examples/**/.terraform.lock.hcl +.idea diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..55e58dd --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @argoyle @peter-svensson diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6dea361 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Opzkit + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1faccaf --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +#!/usr/bin/make -f + +SHELL = /bin/bash +EXAMPLES = $(shell find ./examples/* -maxdepth 1 -type d -not -path '*/\.*') + +.PHONY: examples +examples: $(addprefix example/,$(EXAMPLES)) + +.PHONY: example/% +example/%: + @echo "Processing example: $(notdir $*)" + @terraform -chdir=$* init + @terraform -chdir=$* validate + @terraform -chdir=$* plan + diff --git a/README.md b/README.md new file mode 100644 index 0000000..8e826c1 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# tf-template +Template repository for Terraform modules diff --git a/examples/.gitkeep b/examples/.gitkeep new file mode 100644 index 0000000..e69de29