- manage nomad jobs - create makefile - create gitignore - manage terragrunt environments - add build/deploy jobs
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user