Compare commits
1 Commits
f7b6ba66b2
...
b2041b244a
| Author | SHA1 | Date | |
|---|---|---|---|
| b2041b244a |
@ -16,11 +16,9 @@ jobs:
|
||||
|
||||
- name: Install Terraform/Terragrunt
|
||||
run: |
|
||||
dnf install terraform terragrunt jq -y
|
||||
dnf install terraform terragrunt -y
|
||||
|
||||
- name: Run Terraform Plan
|
||||
env:
|
||||
VAULT_ROLEID: ${{ secrets.TERRAFORM_NOMAD_VAULT_ROLEID }}
|
||||
run: |
|
||||
make plan
|
||||
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,5 +2,3 @@
|
||||
.terraform.lock.hcl
|
||||
environments/*/*.tf
|
||||
plans
|
||||
.venv
|
||||
env
|
||||
|
||||
14
Makefile
14
Makefile
@ -4,14 +4,7 @@ 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
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@echo "Cleaning Terraform files..."
|
||||
find environments -type f -name '*.tf' -exec rm -f "{}" \; && \
|
||||
@ -19,14 +12,15 @@ clean:
|
||||
find environments -type d -name '.terraform' -exec rm -rf "{}" \; && \
|
||||
rm -rf plans
|
||||
|
||||
.PHONY: init
|
||||
init:
|
||||
terragrunt --terragrunt-working-dir $(ENV_DIR) init
|
||||
|
||||
.PHONY: plan
|
||||
plan: init
|
||||
@mkdir -p $(PLAN_DIR)
|
||||
$(call vault_env)
|
||||
terragrunt --terragrunt-working-dir $(ENV_DIR) plan -out=$(PLAN_FILE)
|
||||
|
||||
.PHONY: apply
|
||||
apply:
|
||||
$(call vault_env)
|
||||
terragrunt --terragrunt-working-dir $(ENV_DIR) apply $(PLAN_FILE)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user