292392a024
The provider source moved from git.unkin.net/unkin/artifactapi to artifactapi.k8s.syd1.au.unkin.net/terraform-unkin/artifactapi. .terraform.lock.hcl is gitignored, so a CI runner reusing a workspace/cache keeps a lock pinning the old source; some OpenTofu versions then try to re-resolve git.unkin.net (which isn't a registry) instead of dropping it, failing init. Delete any .terraform.lock.hcl before `terragrunt run --all init -- -upgrade` so providers resolve purely from config.
40 lines
1.5 KiB
Makefile
40 lines
1.5 KiB
Makefile
.PHONY: init plan apply format
|
|
|
|
VAULT_AUTH_METHOD ?= approle
|
|
VAULT_K8S_ROLE ?= woodpecker_terraform_artifactapi
|
|
VAULT_K8S_MOUNT ?= auth/k8s/au/syd1
|
|
VAULT_K8S_JWT_PATH ?= /var/run/secrets/kubernetes.io/serviceaccount/token
|
|
|
|
define vault_env
|
|
@export VAULT_ADDR="https://vault.service.consul:8200" && \
|
|
if [ "$(VAULT_AUTH_METHOD)" = "kubernetes" ]; then \
|
|
export VAULT_TOKEN=$$(vault write -field=token $(VAULT_K8S_MOUNT)/login role=$(VAULT_K8S_ROLE) jwt=$$(cat $(VAULT_K8S_JWT_PATH))); \
|
|
else \
|
|
export VAULT_TOKEN=$$(vault write -field=token auth/approle/login role_id=$$VAULT_ROLEID); \
|
|
fi && \
|
|
export CONSUL_HTTP_TOKEN=$$(vault read -field=token consul_root/au/syd1/creds/terraform-artifactapi)
|
|
endef
|
|
|
|
init:
|
|
@# Drop any stale dependency locks so provider sources are re-resolved
|
|
@# purely from config. Locks are gitignored and CI can reuse a workspace
|
|
@# carrying a lock from an earlier (old provider source) run, which -upgrade
|
|
@# on some OpenTofu versions tries to re-resolve instead of dropping.
|
|
@find . -name '.terraform.lock.hcl' -not -path '*/.git/*' -delete
|
|
@$(call vault_env) && \
|
|
terragrunt run --all --non-interactive init -- -upgrade
|
|
|
|
plan: init
|
|
@$(call vault_env) && \
|
|
terragrunt run --all --parallelism 4 --non-interactive plan
|
|
|
|
apply: init
|
|
@$(call vault_env) && \
|
|
terragrunt run --all --parallelism 2 --non-interactive apply
|
|
|
|
format:
|
|
@echo "Formatting OpenTofu files..."
|
|
@tofu fmt -recursive .
|
|
@echo "Formatting Terragrunt files..."
|
|
@terragrunt hcl fmt
|