-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
928 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: workflow | ||
|
||
on: | ||
pull_request: {} | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: { go-version: 1.16.5 } | ||
|
||
- name: Install Terraform | ||
uses: hashicorp/setup-terraform@v1 | ||
with: { terraform_version: 1.0.0 } | ||
|
||
- name: Install Taskfile | ||
run: curl -sL https://taskfile.dev/install.sh | sh | ||
|
||
- name: Run tests | ||
run: ./bin/task test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"default": true, | ||
"first-header-h1": false, | ||
"first-line-h1": false, | ||
"line_length": false, | ||
"no-multiple-blanks": false, | ||
"fenced-code-language": true, | ||
"no-duplicate-header": { | ||
"siblings_only": true | ||
}, | ||
"code-block-style": { | ||
"style": "fenced" | ||
}, | ||
"single-trailing-newline": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: go-version | ||
name: go version | ||
entry: scripts/check-go-version | ||
language: script | ||
types: [go] | ||
|
||
- repo: git://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.4.0 | ||
hooks: | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- id: check-yaml | ||
- id: detect-private-key | ||
- id: pretty-format-json | ||
args: | ||
- --autofix | ||
- id: trailing-whitespace | ||
|
||
- repo: git://github.com/igorshubovych/markdownlint-cli | ||
rev: v0.26.0 | ||
hooks: | ||
- id: markdownlint | ||
|
||
- repo: git://github.com/antonbabenko/pre-commit-terraform | ||
rev: v1.45.0 | ||
hooks: | ||
- id: terraform_docs | ||
- id: terraform_fmt | ||
|
||
- repo: local | ||
hooks: | ||
- id: gomod | ||
name: gomod | ||
entry: scripts/pre-commit-go-mod | ||
language: script | ||
files: go.mod | ||
pass_filenames: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,22 @@ | ||
# terraform-module-template | ||
# Terraform module template | ||
|
||
[![latest release](https://img.shields.io/github/v/release/appsilon/terraform-module-template?style=flat-square)](https://github.com/appsilon/terraform-module-template/releases/latest) | ||
[![build status](https://img.shields.io/github/workflow/status/appsilon/terraform-module-template/workflow?label=build&logo=github&style=flat-square)](https://github.com/appsilon/terraform-module-template/actions?query=workflow%3Atest) | ||
|
||
Terraform module which creates *describe your intent* resources on AWS. | ||
|
||
## Usage | ||
|
||
Use this template to scaffold a new terraform module. Remember to change the following: | ||
|
||
- The descriptions and build badges in this [README](README.md). | ||
- Update the [basic](examples/simple) example. | ||
- Update the [e2e tests](test/). | ||
|
||
## Authors | ||
|
||
Inspired by [Trussworks](https://github.com/trussworks/terraform-module-template). | ||
|
||
## License | ||
|
||
MIT License. See [LICENSE](LICENSE) for full details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
version: '2' | ||
|
||
env: | ||
TERM: screen-256color | ||
GO111MODULE: on | ||
AWS_DEFAULT_REGION: eu-west-1 | ||
|
||
tasks: | ||
default: | ||
cmds: | ||
- task: test | ||
|
||
test: | ||
desc: Run tests. | ||
cmds: | ||
- task: test-go | ||
- task: test-terraform | ||
|
||
test-go: | ||
desc: Run tests for all Go code. | ||
silent: true | ||
cmds: | ||
- gofmt -s -l -w . | ||
- go vet -v ./... | ||
|
||
test-terraform: | ||
desc: Run tests for all terraform directories. | ||
silent: true | ||
env: | ||
DIRECTORIES: | ||
sh: find . -type f -name '*.tf' -not -path "**/.terraform/*" -print0 | xargs -0I {} dirname {} | sort -u | ||
cmds: | ||
- | | ||
BOLD=$(tput bold) | ||
NORM=$(tput sgr0) | ||
CWD=$PWD | ||
for d in $DIRECTORIES; do | ||
cd $d | ||
echo "${BOLD}$PWD:${NORM}" | ||
if ! terraform fmt -check=true -list=false -recursive=false; then | ||
echo " ✗ terraform fmt" && exit 1 | ||
else | ||
echo " √ terraform fmt" | ||
fi | ||
if ! terraform init -backend=false -input=false -no-color > /dev/null; then | ||
echo " ✗ terraform init" && exit 1 | ||
else | ||
echo " √ terraform init" | ||
fi | ||
if ! terraform validate > /dev/null; then | ||
echo " ✗ terraform validate" && exit 1 | ||
else | ||
echo " √ terraform validate" | ||
fi | ||
cd $CWD | ||
done | ||
e2e: | ||
desc: Run the end 2 end test suite. | ||
silent: true | ||
cmds: | ||
- go test -v ./... -timeout=1h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
# BASIC TERRAFORM CONTENT EXAMPLE | ||
# --------------------------------------------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
# TERRAFORM OUTPUTS EXAMPLE | ||
# --------------------------------------------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
# TERRAFORM VARIABLES EXAMPLE | ||
# --------------------------------------------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module template | ||
|
||
go 1.16 | ||
|
||
require ( | ||
github.com/agext/levenshtein v1.2.2 // indirect | ||
github.com/gruntwork-io/terratest v0.35.6 | ||
github.com/kylelemons/godebug v1.1.0 // indirect | ||
github.com/mitchellh/go-wordwrap v1.0.0 // indirect | ||
github.com/stretchr/testify v1.7.0 // indirect | ||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect | ||
) |
Oops, something went wrong.