Skip to content

Commit

Permalink
Update make details for aws/backup directory
Browse files Browse the repository at this point in the history
  • Loading branch information
OlamideOl1 committed Oct 24, 2023
1 parent b10355a commit f9ab546
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions aws/backup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,6 @@ You may then use the created IAM role as a provider for the `backup-organization

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.14.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 |
<!-- END_TF_DOCS -->
67 changes: 67 additions & 0 deletions aws/backup/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
MODULEFILES := $(wildcard *.tf)
TFLINTRC ?= ../../.tflint.hcl
TFDOCSRC ?= ../../.terraform-docs.yml

.PHONY: default
default: checkfmt validate docs lint

.PHONY: checkfmt
checkfmt: .fmt

.PHONY: fmt
fmt: $(MODULEFILES)
terraform fmt
@touch .fmt

.PHONY: validate
validate: .validate

.PHONY: docs
docs: README.md

.PHONY: lint
lint: .lint

.lint: $(MODULEFILES) .lintinit
tflint --config=$(TFLINTRC)
@touch .lint

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

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

.fmt: $(MODULEFILES)
terraform fmt -check
@touch .fmt

.PHONY: init
init: .init

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

.validate: .init $(MODULEFILES) $(wildcard *.tf.example)
echo | cat - $(wildcard *.tf.example) > test.tf
if AWS_DEFAULT_REGION=us-east-1 terraform validate; then \
rm test.tf; \
touch .validate; \
else \
rm test.tf; \
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 .dependencies .fmt .init .lint .lintinit .terraform* .validate
9 changes: 9 additions & 0 deletions aws/backup/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_version = ">= 0.14.0"

required_providers {
aws = {
version = "~> 5.0"
}
}
}

0 comments on commit f9ab546

Please sign in to comment.