-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
61 lines (51 loc) · 1.64 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
# Directories
TF_DIR = ./Terraform
# Variables
TF_BIN = terraform
TF_VARS_FILE = terraform.tfvars
TF_PLAN_FILE = terraform.tfplan
TF_BACEND_CONFIG_FILE = s3_backend.conf
# Default target
.PHONY: all
all: help
# Display help message
.PHONY: help
help:
@echo "Makefile for ClickHouse Cluster IaC"
@echo ""
@echo "Usage:"
@echo " make tf-all # Initialize & Execute"
@echo " make tf-init # Initialize Terraform"
@echo " make tf-validate # Validates Terraform"
@echo " make tf-plan # Generate Terraform execution plan"
@echo " make tf-apply # Apply Terraform changes"
@echo " make tf-destroy # Destroy resources"
@echo " make clean # Clean Terraform plan files"
# Terraform commands
.PHONY: tf-all
tf-all: tf-init tf-plan tf-apply
.PHONY: tf-init
tf-init:
@echo "Initializing Terraform..."
$(TF_BIN) -chdir=$(TF_DIR) init -backend-config $(TF_BACEND_CONFIG_FILE)
.PHONY: tf-validate
tf-validate:
@echo "Validating Terraform..."
$(TF_BIN) -chdir=$(TF_DIR) validate
.PHONY: tf-plan
tf-plan:
@echo "Generating Terraform execution plan..."
$(TF_BIN) -chdir=$(TF_DIR) plan -var-file=$(TF_VARS_FILE) -out=$(TF_PLAN_FILE)
.PHONY: tf-apply
tf-apply:
@echo "Applying Terraform plan..."
$(TF_BIN) -chdir=$(TF_DIR) apply -var-file=$(TF_VARS_FILE) -auto-approve
.PHONY: tf-destroy
tf-destroy:
@echo "Destroying Terraform-managed infrastructure..."
$(TF_BIN) -chdir=$(TF_DIR) destroy -var-file=$(TF_VARS_FILE) -auto-approve
# Clean Terraform state files
.PHONY: clean
clean:
@echo "Cleaning up Terraform plans..."
rm -f $(TF_PLAN_FILE)