Skip to content

Commit

Permalink
Add missing workflows for Terraform and Open Source README
Browse files Browse the repository at this point in the history
  • Loading branch information
clarissalimab committed Dec 12, 2024
1 parent a52fd43 commit 9937ab0
Show file tree
Hide file tree
Showing 16 changed files with 320 additions and 47 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Terraform
on:
- push

jobs:
checkfmt:
name: Format
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3

- name: Check format
run: make all/checkfmt

validate:
name: Validate
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3

- name: Validate
run: make all/validate

docs:
name: Docs
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Platform Docs
uses: terraform-docs/[email protected]
with:
git-push: true
find-dir: platform
output-file: README.md
output-method: inject
working-dir: .

- name: AWS Docs
uses: terraform-docs/[email protected]
with:
git-push: true
find-dir: aws
output-file: README.md
output-method: inject
working-dir: .

lint:
name: Lint
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3

- name: Setup TFLint
uses: terraform-linters/setup-tflint@v4
with:
tflint_version: v0.44.1

- name: Lint
run: make all/lint
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions .github/workflows/dynamic-readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: update-templates

on:
push:
branches:
- main
workflow_dispatch:

jobs:
update-templates:
permissions:
contents: write
pull-requests: write
pages: write
uses: thoughtbot/templates/.github/workflows/dynamic-readme.yaml@main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
11 changes: 11 additions & 0 deletions .terraform-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
formatter: markdown

output:
file: README.md
mode: inject

settings:
hide-empty: true

# Avoid reading locked version from running validate
lockfile: false
17 changes: 13 additions & 4 deletions elasticache-redis/auth-token/makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
TFLINTRC := ../../.tflint.hcl
TFDOCSRC ?= ../../.terraform-docs.yml
MODULEFILES := $(wildcard *.tf)

.PHONY: default
Expand Down Expand Up @@ -26,11 +27,11 @@ lint: .lint
@touch .lint

.lintinit: $(TFLINTRC)
tflint --init --config=$(TFLINTRC)
tflint --init --config=$(TFLINTRC) --call-module-type=all
@touch .lintinit

README.md: $(MODULEFILES)
terraform-docs markdown table . --output-file README.md
terraform-docs --config "$(TFDOCSRC)" markdown table . --output-file README.md

.fmt: $(MODULEFILES)
terraform fmt -check
Expand All @@ -39,7 +40,7 @@ README.md: $(MODULEFILES)
.PHONY: init
init: .init

.init: versions.tf
.init: versions.tf .dependencies
terraform init -backend=false
@touch .init

Expand All @@ -53,6 +54,14 @@ init: .init
false; \
fi

.dependencies: *.tf
@grep -ohE \
"\b(backend|provider|resource|module) ['\"][[:alpha:]][[:alnum:]]*|\bsource *=.*" *.tf | \
sed "s/['\"]//" | sort | uniq | \
tee /tmp/initdeps | \
diff -q .dependencies - >/dev/null 2>&1 || \
mv /tmp/initdeps .dependencies

.PHONY: clean
clean:
rm -rf .fmt .init .lint .lintinit .terraform .terraform.lock.hcl .validate
rm -rf .dependencies .fmt .init .lint .lintinit .terraform* .validate
17 changes: 13 additions & 4 deletions elasticache-redis/replication-group/makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
TFLINTRC := ../../.tflint.hcl
TFDOCSRC ?= ../../.terraform-docs.yml
MODULEFILES := $(wildcard *.tf)

.PHONY: default
Expand Down Expand Up @@ -26,11 +27,11 @@ lint: .lint
@touch .lint

.lintinit: $(TFLINTRC)
tflint --init --config=$(TFLINTRC)
tflint --init --config=$(TFLINTRC) --call-module-type=all
@touch .lintinit

README.md: $(MODULEFILES)
terraform-docs markdown table . --output-file README.md
terraform-docs --config "$(TFDOCSRC)" markdown table . --output-file README.md

.fmt: $(MODULEFILES)
terraform fmt -check
Expand All @@ -39,7 +40,7 @@ README.md: $(MODULEFILES)
.PHONY: init
init: .init

.init: versions.tf
.init: versions.tf .dependencies
terraform init -backend=false
@touch .init

Expand All @@ -53,6 +54,14 @@ init: .init
false; \
fi

.dependencies: *.tf
@grep -ohE \
"\b(backend|provider|resource|module) ['\"][[:alpha:]][[:alnum:]]*|\bsource *=.*" *.tf | \
sed "s/['\"]//" | sort | uniq | \
tee /tmp/initdeps | \
diff -q .dependencies - >/dev/null 2>&1 || \
mv /tmp/initdeps .dependencies

.PHONY: clean
clean:
rm -rf .fmt .init .lint .lintinit .terraform .terraform.lock.hcl .validate
rm -rf .dependencies .fmt .init .lint .lintinit .terraform* .validate
19 changes: 14 additions & 5 deletions kafka/makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
TFLINTRC := ../.tflint.hcl
TFLINTRC := ../../.tflint.hcl
TFDOCSRC ?= ../../.terraform-docs.yml
MODULEFILES := $(wildcard *.tf)

.PHONY: default
Expand Down Expand Up @@ -26,11 +27,11 @@ lint: .lint
@touch .lint

.lintinit: $(TFLINTRC)
tflint --init --config=$(TFLINTRC)
tflint --init --config=$(TFLINTRC) --call-module-type=all
@touch .lintinit

README.md: $(MODULEFILES)
terraform-docs markdown table . --output-file README.md
terraform-docs --config "$(TFDOCSRC)" markdown table . --output-file README.md

.fmt: $(MODULEFILES)
terraform fmt -check
Expand All @@ -39,7 +40,7 @@ README.md: $(MODULEFILES)
.PHONY: init
init: .init

.init: versions.tf
.init: versions.tf .dependencies
terraform init -backend=false
@touch .init

Expand All @@ -53,6 +54,14 @@ init: .init
false; \
fi

.dependencies: *.tf
@grep -ohE \
"\b(backend|provider|resource|module) ['\"][[:alpha:]][[:alnum:]]*|\bsource *=.*" *.tf | \
sed "s/['\"]//" | sort | uniq | \
tee /tmp/initdeps | \
diff -q .dependencies - >/dev/null 2>&1 || \
mv /tmp/initdeps .dependencies

.PHONY: clean
clean:
rm -rf .fmt .init .lint .lintinit .terraform .terraform.lock.hcl .validate
rm -rf .dependencies .fmt .init .lint .lintinit .terraform* .validate
4 changes: 4 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export TF_CLI_CONFIG_FILE := $(CURDIR)/.terraformrc
MODULES := $(foreach main,$(wildcard */*/main.tf),$(subst /main.tf,,$(main)))
MODULEMAKEFILES := $(foreach module,$(MODULES),$(module)/makefile)
MAKEMODULES := $(foreach module,$(MODULES),$(module)/default)
SUBMODULESCOMMAND ?= default
CLEANMODULES := $(foreach module,$(MODULES),$(module)/clean)

.PHONY: default
Expand Down Expand Up @@ -53,3 +54,6 @@ clean: $(CLEANMODULES)

layers/%/package.zip: layers/%/*
$(MAKE) -C layers/"$*"

all/%:
$(MAKE) modules SUBMODULESCOMMAND=$(*)
19 changes: 14 additions & 5 deletions makefiles/terraform.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
TFLINTRC := ../../.tflint.hcl
MODULEFILES := $(wildcard *.tf)
TFLINTRC ? =../../.tflint.hcl
TFDOCSRC ? =../../.terraform-docs.yml

.PHONY: default
default: checkfmt validate docs lint
Expand All @@ -26,11 +27,11 @@ lint: .lint
@touch .lint

.lintinit: $(TFLINTRC)
tflint --init --config=$(TFLINTRC)
tflint --init --config=$(TFLINTRC) --call-module-type=all
@touch .lintinit

README.md: $(MODULEFILES)
terraform-docs markdown table . --output-file README.md
terraform-docs --config "$(TFDOCSRC)" markdown table . --output-file README.md

.fmt: $(MODULEFILES)
terraform fmt -check
Expand All @@ -39,7 +40,7 @@ README.md: $(MODULEFILES)
.PHONY: init
init: .init

.init: versions.tf
.init: versions.tf .dependencies
terraform init -backend=false
@touch .init

Expand All @@ -53,6 +54,14 @@ init: .init
false; \
fi

.dependencies: *.tf
@grep -ohE \
"\b(backend|provider|resource|module) ['\"][[:alpha:]][[:alnum:]]*|\bsource *=.*" *.tf | \
sed "s/['\"]//" | sort | uniq | \
tee /tmp/initdeps | \
diff -q .dependencies - >/dev/null 2>&1 || \
mv /tmp/initdeps .dependencies

.PHONY: clean
clean:
rm -rf .fmt .init .lint .lintinit .terraform .terraform.lock.hcl .validate
rm -rf .dependencies .fmt .init .lint .lintinit .terraform* .validate
17 changes: 13 additions & 4 deletions rds-postgres/admin-login/makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
TFLINTRC := ../../.tflint.hcl
TFDOCSRC ?= ../../.terraform-docs.yml
MODULEFILES := $(wildcard *.tf)

.PHONY: default
Expand Down Expand Up @@ -26,11 +27,11 @@ lint: .lint
@touch .lint

.lintinit: $(TFLINTRC)
tflint --init --config=$(TFLINTRC)
tflint --init --config=$(TFLINTRC) --call-module-type=all
@touch .lintinit

README.md: $(MODULEFILES)
terraform-docs markdown table . --output-file README.md
terraform-docs --config "$(TFDOCSRC)" markdown table . --output-file README.md

.fmt: $(MODULEFILES)
terraform fmt -check
Expand All @@ -39,7 +40,7 @@ README.md: $(MODULEFILES)
.PHONY: init
init: .init

.init: versions.tf
.init: versions.tf .dependencies
terraform init -backend=false
@touch .init

Expand All @@ -53,6 +54,14 @@ init: .init
false; \
fi

.dependencies: *.tf
@grep -ohE \
"\b(backend|provider|resource|module) ['\"][[:alpha:]][[:alnum:]]*|\bsource *=.*" *.tf | \
sed "s/['\"]//" | sort | uniq | \
tee /tmp/initdeps | \
diff -q .dependencies - >/dev/null 2>&1 || \
mv /tmp/initdeps .dependencies

.PHONY: clean
clean:
rm -rf .fmt .init .lint .lintinit .terraform .terraform.lock.hcl .validate
rm -rf .dependencies .fmt .init .lint .lintinit .terraform* .validate
17 changes: 13 additions & 4 deletions rds-postgres/cloudwatch-alarms/makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
TFLINTRC := ../../.tflint.hcl
TFDOCSRC ?= ../../.terraform-docs.yml
MODULEFILES := $(wildcard *.tf)

.PHONY: default
Expand Down Expand Up @@ -26,11 +27,11 @@ lint: .lint
@touch .lint

.lintinit: $(TFLINTRC)
tflint --init --config=$(TFLINTRC)
tflint --init --config=$(TFLINTRC) --call-module-type=all
@touch .lintinit

README.md: $(MODULEFILES)
terraform-docs markdown table . --output-file README.md
terraform-docs --config "$(TFDOCSRC)" markdown table . --output-file README.md

.fmt: $(MODULEFILES)
terraform fmt -check
Expand All @@ -39,7 +40,7 @@ README.md: $(MODULEFILES)
.PHONY: init
init: .init

.init: versions.tf
.init: versions.tf .dependencies
terraform init -backend=false
@touch .init

Expand All @@ -53,6 +54,14 @@ init: .init
false; \
fi

.dependencies: *.tf
@grep -ohE \
"\b(backend|provider|resource|module) ['\"][[:alpha:]][[:alnum:]]*|\bsource *=.*" *.tf | \
sed "s/['\"]//" | sort | uniq | \
tee /tmp/initdeps | \
diff -q .dependencies - >/dev/null 2>&1 || \
mv /tmp/initdeps .dependencies

.PHONY: clean
clean:
rm -rf .fmt .init .lint .lintinit .terraform .terraform.lock.hcl .validate
rm -rf .dependencies .fmt .init .lint .lintinit .terraform* .validate
Loading

0 comments on commit 9937ab0

Please sign in to comment.