-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
41 lines (35 loc) · 1.03 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
# Terraform parameters
ENVIRONMENT := lab
TERRAFORM := terraform
# TF_FILES_PATH := src
TF_BACKEND_CONF := configuration/backend
TF_VARIABLES := configuration/tfvars
all: init changes deploy
init:
$(info Initializing Terraform...)
$(TERRAFORM) init \
-backend-config="$(TF_BACKEND_CONF)/$(ENVIRONMENT).conf" $(TF_FILES_PATH)
changes:
$(info Get changes in infrastructure resources...)
$(TERRAFORM) plan \
-var-file="$(TF_VARIABLES)/terraform.tfvars" \
-out "output/tf.$(ENVIRONMENT).plan" \
deploy: changes
$(info Deploying infrastructure...)
$(TERRAFORM) apply \
output/tf.$(ENVIRONMENT).plan
destroy:
$(info Destroying infrastructure...)
$(TERRAFORM) destroy \
-auto-approve \
-var-file="$(TF_VARIABLES)/terraform.tfvars"
$(RM) -r .terraform
$(RM) -r output/tf.$(ENVIRONMENT).plan
$(RM) -r state/terraform*
$(RM) -r .terraform.lock.hcl
clean:
$(info Cleaning unused files...)
$(RM) -r .terraform
$(RM) -r output/tf.$(ENVIRONMENT).plan
$(RM) -r state/terraform*
$(RM) -r .terraform.lock.hcl