-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (61 loc) · 2.21 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
.PHONY: all
TF_VERSION=1.2.1
NODE_VERSION=14.x
all: install-dependencies test/all
install-dependencies: install/terraform install/nodejs install/checkov
# -----------------------------------------------------------------------------------
# Dependencies install targets
# -----------------------------------------------------------------------------------
install/terraform:
@echo "INSTALLING TERRAFORM version ${TF_VERSION}..."
@curl https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip --output /opt/terraform.zip
@unzip -o /opt/terraform.zip -d /usr/local/bin/
@rm -f /opt/terraform.zip
@terraform -version
@echo ""
install/nodejs:
@echo "INSTALLING NODE.js version ${NODE_VERSION}..."
@curl -sL https://rpm.nodesource.com/setup_${NODE_VERSION} | bash -
@yum install -y nodejs
@node -v
@npm -v
@echo ""
install/checkov:
@echo "INSTALLING CHECKOV..."
@/usr/local/bin/pip3.8 install dataclasses && /usr/local/bin/pip3.8 install checkov --upgrade
@checkov --version
@echo ""
# -----------------------------------------------------------------------------------
# Test Targets
# -----------------------------------------------------------------------------------
test/checkov:
@echo "Running Checkov for Terrafrom in ${ENV}"
@cd terraform/${ENV} && \
checkov -d . --quiet --framework terraform --download-external-modules true
# -----------------------------------------------------------------------------------
# Terraform Targets
# -----------------------------------------------------------------------------------
ENV?=
terraform/init:
@echo "Terraform Init in ${ENV}"
@cd terraform/${ENV} && \
rm -rf tfplan-${ENV} .terraform/ && \
terraform init
terraform/plan:
@echo "Terraform Plan in ${ENV}"
@cd terraform/${ENV} && \
terraform plan \
-out=tfplan-${ENV}
terraform/apply:
@echo "Terraform Apply in ${ENV}"
@cd terraform/${ENV} && \
terraform apply tfplan-${ENV}
terraform/plan-destroy:
@echo "Terraform **** Destroy **** Plan in ${ENV}"
@cd terraform/${ENV} && \
terraform plan -destroy \
-out=tfplan-destroy-${ENV}
terraform/apply-destroy:
@echo "Terraform **** Destroy **** Apply in ${ENV}"
@cd terraform/${ENV} && \
terraform apply tfplan-destroy-${ENV}