Skip to content

Commit b2592b5

Browse files
committed
updates Makefile to support different targets
1 parent e7164e0 commit b2592b5

File tree

1 file changed

+51
-12
lines changed

1 file changed

+51
-12
lines changed

Makefile

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,74 @@ RED = \033[0;31m
44
NC = \033[0m
55

66
# run all
7-
all: build plan apply
7+
all: init validate plan apply run-tests destroy
88
@echo "$(GREEN)✓ 'make all' has completed $(NC)\n"
99

1010
# initial terraform setup
1111
init: ; @echo "$(GREEN)✓ Initializing terraform $(NC)\n"
12-
@cd test/fixtures/tf_module/ && terraform get && terraform init
12+
@terraform init -input=false -lock=true \
13+
-upgrade -force-copy -backend=true -get=true \
14+
-get-plugins=true -verify-plugins=true \
15+
tests/fixtures/tf_module
1316
@$(MAKE) -s post-action
1417

15-
# building a function
16-
build: ; @echo "$(GREEN)✓ Building a function $(NC)\n"
17-
@cd test/fixtures/tf_module/function && zip function.zip *.py
18+
update: ; @echo "$(GREEN)✓ Updating terraform $(NC)\n"
19+
@terraform get -update tests/fixtures/tf_module
20+
@$(MAKE) -s post-action
21+
22+
validate: ; @echo "$(GREEN)✓ Updating terraform $(NC)\n"
23+
@terraform validate -check-variables=true \
24+
-var-file=tests/fixtures/tf_module/testing.tfvars \
25+
tests/fixtures/tf_module
1826
@$(MAKE) -s post-action
1927

20-
# plan terraform
28+
# terraform plan
2129
plan: ; @echo "$(GREEN)✓ Planning terraform $(NC)\n"
22-
@cd test/fixtures/tf_module/ && terraform plan -var-file=testing.tfvars --out out.terraform
30+
@terraform plan -lock=true -input=false \
31+
-parallelism=4 -refresh=true \
32+
-var-file=tests/fixtures/tf_module/testing.tfvars \
33+
tests/fixtures/tf_module
2334
@$(MAKE) -s post-action
2435

2536
# apply terraform
2637
apply: ; @echo "$(GREEN)✓ Applying terraform $(NC)\n"
27-
@cd test/fixtures/tf_module/ && terraform apply out.terraform
38+
@terraform apply -lock=true -input=false \
39+
-auto-approve=true -parallelism=4 -refresh=true \
40+
-var-file=tests/fixtures/tf_module/testing.tfvars \
41+
tests/fixtures/tf_module
42+
@$(MAKE) -s post-action
43+
44+
run-tests: ; @echo "$(GREEN)✓ Running rspec tests $(NC)\n"
45+
@bundle exec rspec -c -f doc --default-path '.' -P 'tests/scenarios/test_module.rb'
46+
@$(MAKE) -s post-action
47+
48+
# building a function
49+
build: ; @echo "$(GREEN)✓ Building a function $(NC)\n"
50+
@cd tests/fixtures/tf_module/function && zip function.zip *.py
2851
@$(MAKE) -s post-action
2952

30-
# destroy all resources and amivar.tf file
53+
# destroy all resources
3154
destroy: ; @echo "$(RED)✓ Destroying terraform resources $(NC)\n"
32-
@cd test/fixtures/tf_module/ && terraform destroy -force -var-file=testing.tfvars
55+
@terraform destroy -force -input=false -parallelism=4 -refresh=true \
56+
-var-file=tests/fixtures/tf_module/testing.tfvars \
57+
tests/fixtures/tf_module
58+
@rm terraform.tfstate*
59+
@$(MAKE) -s post-action
60+
61+
clean: ; @echo "$(RED)✓ Cleaning directory $(NC)\n"
62+
@rm -rf test/fixtures/tf_module/.terraform
63+
@rm -f terraform.tfstate*
64+
@rm -f test/fixtures/tf_module/function/function.zip
65+
@$(MAKE) -s post-action
66+
67+
tflint: ; @echo "$(RED)✓ Running tflint $(NC)\n"
68+
@cd module && tflint
69+
@$(MAKE) -s post-action
70+
71+
deps: ; @echo "$(RED)✓ Installing dependencies $(NC)\n"
72+
@gem install bundler
73+
@bundle check || bundle install
3374
@$(MAKE) -s post-action
34-
.PHONY: destroy
3575

36-
# run post actions
3776
post-action: ; @echo "$(BLUE)✓ Done. $(NC)\n"
3877
.PHONY: post-action

0 commit comments

Comments
 (0)