-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
125 lines (101 loc) · 5.08 KB
/
Makefile
File metadata and controls
125 lines (101 loc) · 5.08 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
ENV_FILE_EXISTS = 0
# keep the Makefile clean of env variables and use a .env file instead
ifneq (,$(wildcard ./.env))
include .env
export
ENV_FILE_EXISTS = 1
endif
MODULES := $(wildcard modules/*)
format: ## Format all the code and make it look pretty
$(info --- "Formatting code")
terragrunt hclfmt
terraform fmt -recursive .
.PHONY: format
module-docs: ## Generate the Terraform documentation
$(info --- Generating Terraform documentation)
@for module in $(MODULES); \
do echo "## $$PWD/$$module"; \
terraform-docs markdown document --hide requirements --escape=false --sort-by required $$PWD/$$module > $$PWD/$$module/README.md; \
done
.PHONY: module-docs
clean-tf: ## Remove the .tf cache directories and files
$(info --- Clean Terragrunt Cache)
find . -type d -name ".terraform" -prune -exec rm -rf {} \;
find . -type d -name ".terragrunt-cache" -prune -exec rm -rf {} \;
find . -type f -name ".terraform.lock.hcl" -prune -exec rm -f {} \;
.PHONY: clean-tf
function-create-package: ## Compiles the provided function app
$(info --- Creating the provided function deployment package)
scripts/create-package-functionapp.sh
.PHONY: function-create-package
function-taint-tfstate: ## Taints the Function resources to ensure redeploy
$(info --- Tainting Function state entries)
terragrunt taint --terragrunt-working-dir environment/infrastructure/prod/management-sub/function-app null_resource.function_app_publish
.PHONY: function-taint-tfstate
function-deploy-function-source: ## Deploys the function source to Function App resource
$(info --- Deploying the Function App source code)
terragrunt run-all apply --terragrunt-non-interactive --terragrunt-working-dir environment/infrastructure/prod/management-sub/function-app
.PHONY: function-deploy-function-source
function-redeploy-function: ## Redeploys the Function source code
function-redeploy-function: function-create-package function-taint-tfstate function-deploy-function-source
.PHONY: function-redeploy-function
validate-all: ## Validates ALL the TF files and config
$(info --- Validating all Terraform code and config)
terragrunt run-all validate --terragrunt-non-interactive --terragrunt-working-dir environment
.PHONY: validate-all
validate-infra: ## Validates the Infrastructure TF files and config
$(info --- Validating Infrastructure Terraform code and config)
terragrunt run-all validate --terragrunt-non-interactive --terragrunt-working-dir environment/infrastructure
.PHONY: validate-infra
validate-policy: ## Validates the Policy TF files and config
$(info --- Validating Policy Terraform code and config)
terragrunt run-all validate --terragrunt-non-interactive --terragrunt-working-dir environment/policy
.PHONY: validate-policy
plan-all: ## Terraform plan
$(info --- Running Terraform plan)
terragrunt run-all plan --terragrunt-non-interactive --terragrunt-working-dir environment
.PHONY: plan-all
plan-infra: ## Plan the Infrastructure
$(info --- Running Terraform plan on Infrastructure)
terragrunt run-all plan --terragrunt-non-interactive --terragrunt-working-dir environment/infrastructure
.PHONY: plan-infra
plan-policy: ## Plan the Policy changes
$(info --- Running Terraform plan on Policy)
terragrunt run-all plan --terragrunt-non-interactive --terragrunt-working-dir environment/policy
.PHONY: plan-policy
apply-all: ## Terraform apply
$(info --- Running Terraform apply)
terragrunt run-all apply --terragrunt-non-interactive --terragrunt-working-dir environment
.PHONY: apply-all
apply-infra: ## Apply the Infrastructure
$(info --- Running Terraform apply on Infrastructure)
terragrunt run-all apply --terragrunt-non-interactive --terragrunt-working-dir environment/infrastructure
.PHONY: apply-infra
apply-policy: ## Apply the Policy changes
$(info --- Running Terraform apply on Policy)
terragrunt run-all apply --terragrunt-non-interactive --terragrunt-working-dir environment/policy
.PHONY: apply-policy
destroy-all: ## Terraform destroy
$(info --- Running Terraform destroy)
terragrunt run-all destroy --terragrunt-non-interactive --terragrunt-working-dir environment
.PHONY: destroy-all
destroy-infra: ## Destroy the Infrastructure
$(info --- Running Terraform destroy on Infrastructure)
terragrunt run-all destroy --terragrunt-non-interactive --terragrunt-working-dir environment/infrastructure
.PHONY: destroy-infra
destroy-policy: ## Destroy the Policy changes
$(info --- Running Terraform destroy on Policy)
terragrunt run-all destroy --terragrunt-non-interactive --terragrunt-working-dir environment/policy
.PHONY: destroy-policy
upgrade-tf: ## Upgrade all the TF Modules
$(info --- Upgrading all Terraform Module versions)
terragrunt run-all init -upgrade --terragrunt-non-interactive --terragrunt-working-dir environment
.PHONY: upgrade-tf
sp-login: ## Run az login for the SP
$(info --- Running az login for the SP)
@az login --service-principal --username ${ARM_CLIENT_ID} --password ${ARM_CLIENT_SECRET} --tenant ${ARM_TENANT_ID}
.PHONY: sp-login
help: ## Show this help
@egrep -h '\s##\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-35s\033[0m %s\n", $$1, $$2}'
.PHONY:help
.DEFAULT_GOAL := help