Skip to content

Commit 318d343

Browse files
committed
Added running script for terraform inside makefile
1 parent f758ba6 commit 318d343

File tree

1 file changed

+95
-3
lines changed

1 file changed

+95
-3
lines changed

Makefile

Lines changed: 95 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export CI_REGISTRY ?= $(ARGS).dkr.ecr.ap-southeast-1.amazonaws.com
2626
export CI_PROJECT_PATH ?= devopscorner
2727
export CI_PROJECT_NAME ?= laravel
2828

29-
IMAGE = $(CI_REGISTRY)/${CI_PROJECT_PATH}/${PROJECT_NAME}
30-
DIR = $(shell pwd)
31-
VERSION ?= 1.3.0
29+
IMAGE = $(CI_REGISTRY)/${CI_PROJECT_PATH}/${PROJECT_NAME}
30+
DIR = $(shell pwd)
31+
VERSION ?= 1.3.0
3232

3333
export BASE_IMAGE=ubuntu
3434
export BASE_VERSION=22.04
@@ -212,3 +212,95 @@ helm-push-lab:
212212
@echo "=============================================================="
213213
@cd ${PATH_HELM} && ./helm-push-lab.sh
214214
@echo '- DONE -'
215+
216+
# =========================== #
217+
# PROVISIONING INFRA CORE #
218+
# =========================== #
219+
.PHONY: tf-core-init tf-core-create-workspace tf-core-select-workspace tf-core-plan tf-core-apply
220+
tf-core-init:
221+
@echo "=============================================================="
222+
@echo " Task : Terraform Init "
223+
@echo " Date/Time : `date` "
224+
@echo "=============================================================="
225+
@cd $(TF_CORE) && terraform init $(ARGS)
226+
@echo '- DONE -'
227+
tf-core-create-workspace:
228+
@echo "=============================================================="
229+
@echo " Task : Terraform Create Workspace "
230+
@echo " Date/Time : `date` "
231+
@echo "=============================================================="
232+
@cd $(TF_CORE) && terraform workspace new $(ARGS)
233+
@echo '- DONE -'
234+
tf-core-select-workspace:
235+
@echo "=============================================================="
236+
@echo " Task : Terraform Select Workspace "
237+
@echo " Date/Time : `date` "
238+
@echo "=============================================================="
239+
@cd $(TF_CORE) && terraform workspace select $(ARGS)
240+
@echo '- DONE -'
241+
tf-core-plan:
242+
@echo "=============================================================="
243+
@echo " Task : Terraform Plan Provisioning "
244+
@echo " Date/Time : `date` "
245+
@echo "=============================================================="
246+
@cd $(TF_CORE) && terraform plan $(ARGS)
247+
@echo '- DONE -'
248+
tf-core-apply:
249+
@echo "=============================================================="
250+
@echo " Task : Provisioning Terraform "
251+
@echo " Date/Time : `date` "
252+
@echo "=============================================================="
253+
@cd $(TF_CORE) && terraform apply -auto-approve
254+
@echo '- DONE -'
255+
256+
# ================================ #
257+
# PROVISIONING RESOURCES INFRA #
258+
# ================================ #
259+
.PHONY: tf-infra-init tf-infra-create-workspace tf-infra-select-workspace tf-infra-plan tf-infra-apply tf-infra-resource
260+
tf-infra-init:
261+
@echo "=============================================================="
262+
@echo " Task : Terraform Init "
263+
@echo " Date/Time : `date` "
264+
@echo "=============================================================="
265+
@cd $(TF_RESOURCES)/$(INFRA_RESOURCES) && terraform init $(ARGS)
266+
@echo '- DONE -'
267+
tf-infra-create-workspace:
268+
@echo "=============================================================="
269+
@echo " Task : Terraform Create Workspace "
270+
@echo " Date/Time : `date` "
271+
@echo "=============================================================="
272+
@cd $(TF_RESOURCES)/$(INFRA_RESOURCES) && terraform workspace new $(ARGS)
273+
@echo '- DONE -'
274+
tf-infra-select-workspace:
275+
@echo "=============================================================="
276+
@echo " Task : Terraform Select Workspace "
277+
@echo " Date/Time : `date` "
278+
@echo "=============================================================="
279+
@cd $(TF_RESOURCES)/$(INFRA_RESOURCES) && terraform workspace select $(ARGS)
280+
@echo '- DONE -'
281+
tf-infra-plan:
282+
@echo "=============================================================="
283+
@echo " Task : Terraform Plan Provisioning "
284+
@echo " Date/Time : `date` "
285+
@echo "=============================================================="
286+
@cd $(TF_RESOURCES)/$(INFRA_RESOURCES) && terraform plan $(ARGS)
287+
@echo '- DONE -'
288+
tf-infra-apply:
289+
@echo "=============================================================="
290+
@echo " Task : Provisioning Terraform "
291+
@echo " Date/Time : `date` "
292+
@echo "=============================================================="
293+
@cd $(TF_RESOURCES)/$(INFRA_RESOURCES) && terraform apply -auto-approve $(ARGS)
294+
@echo '- DONE -'
295+
296+
# =============================== #
297+
# PROVISIONING SPESIFIC INFRA #
298+
# =============================== #
299+
.PHONY: tf-infra-resource
300+
tf-infra-resource:
301+
@echo "=============================================================="
302+
@echo " Task : Terraform Command $(ARGS)"
303+
@echo " Date/Time : `date` "
304+
@echo "=============================================================="
305+
@cd $(TF_RESOURCES)/$(INFRA_RESOURCES) && terraform $(ARGS)
306+
@echo '- DONE -'

0 commit comments

Comments
 (0)