forked from dgozalo/terraform-eks-jx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (58 loc) · 1.94 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
ifeq ($(OS),Windows_NT)
OS := windows
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OS := linux
endif
ifeq ($(UNAME_S),Darwin)
OS := darwin
endif
endif
TERRAFORM_VAR_FILE ?= terraform.tfvars
TFSEC = bin/tfsec
.DEFAULT_GOAL := help
.PHONY: help
help:
@grep -h -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: apply
apply: ## Applies Terraform plan w/ auto approve
@test -s $(TERRAFORM_VAR_FILE) || { echo "The 'apply' rule assumes that variables are provided $(TERRAFORM_VAR_FILE)"; exit 1; }
terraform apply -auto-approve --var-file $(TERRAFORM_VAR_FILE)
.PHONY: destroy
destroy: ## Destroys Terraform infrastructure w/ auto approve
terraform destroy -auto-approve --var-file $(TERRAFORM_VAR_FILE)
.PHONY: init
init: ## Init the terraform module
terraform init
.PHONY: tf-version
tf-version: ## checks the terraform version
terraform version
.PHONY: lint
lint: init tf-version fmt ## Verifies Terraform syntax
terraform validate
.PHONY: fmt
fmt: ## Reformats Terraform files accoring to standard
terraform fmt -diff -recursive
# There is a bug in the latest version which causes a panic.
$(TFSEC): bin ## Installs tfsec
curl -L "$$(curl -s https://api.github.com/repos/liamg/tfsec/releases/tags/v0.21.0 | grep -o -E "https://.+?-$(OS)-amd64(.exe)?")" > $(TFSEC);\
chmod +x $(TFSEC)
check-tfsec: ## Check if tfsec is installed
$(TFSEC) --version
.PHONY: tfsec
tfsec: $(TFSEC) check-tfsec ## Runs tfsec
$(TFSEC) -e AWS002,AWS017
bin: ## Create bin directory for test binaries
mkdir bin
.PHONY: test
test: ## Runs terratest
cd test && AWS_REGION=us-east-1 go test -timeout 1h -v
.PHONY: clean
clean: ## Deletes temporary files
rm -rf report
rm -f jx-requirements.yml
rm -rf bin
.PHONY: markdown-table
markdown-table: ## Creates markdown tables for in- and output of this module
terraform-docs markdown table .