All checks were successful
Build / build (pull_request) Successful in 42s
- manage nomad jobs - create makefile - create gitignore - manage terragrunt environments - add build/deploy jobs
34 lines
1.1 KiB
Makefile
34 lines
1.1 KiB
Makefile
SHELL := /bin/bash
|
|
ENVIRONMENT ?= au-syd1
|
|
ENV_DIR = environments/$(ENVIRONMENT)
|
|
PLAN_DIR = plans
|
|
PLAN_FILE = ../../$(PLAN_DIR)/$(ENVIRONMENT).plan
|
|
|
|
.PHONY: clean init plan apply
|
|
|
|
define vault_env
|
|
@export VAULT_ADDR="https://vault.service.consul:8200" && \
|
|
export VAULT_TOKEN=$$(vault write -field=token auth/approle/login role_id=$$VAULT_ROLEID) && \
|
|
export $$(vault read -format=json kv/data/service/terraform/nomad | jq -r '.data.data | to_entries[] | "\(.key)=\(.value)"')
|
|
endef
|
|
|
|
clean:
|
|
@echo "Cleaning Terraform files..."
|
|
find environments -type f -name '*.tf' -exec rm -f "{}" \; && \
|
|
find environments -type f -name '.terraform.lock.hcl' -exec rm -f "{}" \; && \
|
|
find environments -type d -name '.terraform' -exec rm -rf "{}" \; && \
|
|
rm -rf plans
|
|
|
|
init:
|
|
$(call vault_env) && \
|
|
terragrunt --terragrunt-working-dir $(ENV_DIR) init
|
|
|
|
plan: init
|
|
@mkdir -p $(PLAN_DIR)
|
|
$(call vault_env) && \
|
|
terragrunt --terragrunt-working-dir $(ENV_DIR) plan -out=$(PLAN_FILE)
|
|
|
|
apply:
|
|
$(call vault_env) && \
|
|
terragrunt --terragrunt-working-dir $(ENV_DIR) apply $(PLAN_FILE)
|