-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (68 loc) · 1.73 KB
/
Makefile
File metadata and controls
94 lines (68 loc) · 1.73 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
.PHONY: deps format converge verify destroy shell test kitchen build circleci-build
IMAGE_NAME := qualimente/terraform-infra-dev
IMAGE_TAG := 0.9
FQ_IMAGE := $(IMAGE_NAME):$(IMAGE_TAG)
TERRAFORM_OPTS :=
terraform = @$(call execute,terraform $(1) $(TERRAFORM_OPTS))
tflint = @$(call execute,tflint $(1))
terraform-docs = @$(call execute,terraform-docs $(1))
KITCHEN_OPTS :=
kitchen = @$(call execute,bundle exec kitchen $(1) $(KITCHEN_OPTS))
AWS_AUTH_VARS :=
ifdef AWS_PROFILE
AWS_AUTH_VARS += $(AWS_AUTH_VARS) -e AWS_PROFILE=$(AWS_PROFILE)
endif
ifdef AWS_ACCESS_KEY_ID
AWS_AUTH_VARS += $(AWS_AUTH_VARS) -e AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID)
endif
ifdef AWS_SECRET_ACCESS_KEY
AWS_AUTH_VARS += $(AWS_AUTH_VARS) -e AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY)
endif
ifdef AWS_SESSION_TOKEN
AWS_AUTH_VARS += $(AWS_AUTH_VARS) -e AWS_SESSION_TOKEN=$(AWS_SESSION_TOKEN)
endif
AWS_OPTS := $(AWS_AUTH_VARS) -e AWS_REGION=$(AWS_REGION)
define execute
if [ -z "$(CI)" ]; then \
docker run --rm -it \
$(AWS_OPTS) \
-e USER=root \
-v $(shell pwd):/module \
-v $(HOME)/.aws:/root/.aws:ro \
-v $(HOME)/.netrc:/root/.netrc:ro \
$(FQ_IMAGE) \
$(1); \
else \
echo $(1); \
$(1); \
fi;
endef
shell:
@$(call execute,sh,)
deps:
@set -e
@if test -z $(CI); then \
docker pull $(FQ_IMAGE); \
fi;
init:
@$(call terraform,init)
format:
@$(call terraform,fmt)
lint:
@$(call tflint,)
converge:
@$(call kitchen,converge)
verify:
@$(call kitchen,verify)
destroy:
@$(call kitchen,destroy)
test:
@$(call kitchen,test)
kitchen:
@$(call kitchen,$(COMMAND))
docs:
@$(call terraform-docs,markdown interface.tf > interface.md)
all: deps init format lint converge verify docs
circleci-build:
@circleci build \
$(AWS_OPTS)