-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (60 loc) · 2.31 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
BLUE = \033[0;34m
GREEN = \033[0;32m
RED = \033[0;31m
NC = \033[0m
# run all
all: init validate plan apply run-tests destroy
@echo "$(GREEN)✓ 'make all' has completed $(NC)\n"
# initial terraform setup
init: ; @echo "$(GREEN)✓ Initializing terraform $(NC)\n"
@terraform init -input=false -lock=true \
-upgrade -force-copy -backend=true -get=true \
-get-plugins=true -verify-plugins=true \
tests/fixtures/tf_module
@$(MAKE) -s post-action
update: ; @echo "$(GREEN)✓ Updating terraform $(NC)\n"
@terraform get -update tests/fixtures/tf_module
@$(MAKE) -s post-action
validate: ; @echo "$(GREEN)✓ Updating terraform $(NC)\n"
@terraform validate -check-variables=true \
-var-file=tests/fixtures/tf_module/testing.tfvars \
tests/fixtures/tf_module
@terraform validate -check-variables=false module
@$(MAKE) -s post-action
# terraform plan
plan: ; @echo "$(GREEN)✓ Planning terraform $(NC)\n"
@terraform plan -lock=true -input=false \
-parallelism=4 -refresh=true \
-var-file=tests/fixtures/tf_module/testing.tfvars \
tests/fixtures/tf_module
@$(MAKE) -s post-action
# apply terraform
apply: ; @echo "$(GREEN)✓ Applying terraform $(NC)\n"
@terraform apply -lock=true -input=false \
-auto-approve=true -parallelism=4 -refresh=true \
-var-file=tests/fixtures/tf_module/testing.tfvars \
tests/fixtures/tf_module
@$(MAKE) -s post-action
run-tests: ; @echo "$(GREEN)✓ Running rspec tests $(NC)\n"
@bundle exec rspec -c -f doc --default-path '.' -P 'tests/scenarios/test_module.rb'
@$(MAKE) -s post-action
# destroy all resources
destroy: ; @echo "$(RED)✓ Destroying terraform resources $(NC)\n"
@terraform destroy -force -input=false -parallelism=4 -refresh=true \
-var-file=tests/fixtures/tf_module/testing.tfvars \
tests/fixtures/tf_module
@rm terraform.tfstate*
@$(MAKE) -s post-action
clean: ; @echo "$(RED)✓ Cleaning directory $(NC)\n"
@rm -rf test/fixtures/tf_module/.terraform
@rm -f terraform.tfstate*
@$(MAKE) -s post-action
tflint: ; @echo "$(RED)✓ Running tflint $(NC)\n"
@cd module && tflint
@$(MAKE) -s post-action
deps: ; @echo "$(RED)✓ Installing dependencies $(NC)\n"
@gem install bundler
@bundle check || bundle install
@$(MAKE) -s post-action
post-action: ; @echo "$(BLUE)✓ Done. $(NC)\n"
.PHONY: post-action