9351ea30a9
pre-commit runs `tofu validate`/tflint on modules/artifactapi standalone, where no required_providers was declared, so OpenTofu inferred hashicorp/artifactapi and failed (and tflint flagged missing required_version/version constraint). - add modules/artifactapi/versions.tf declaring required_version and the artifactapi provider (source = the registry, version >= 0.1.2) - drop the now-duplicate required_providers from root.hcl's generated backend.tf; keep the provider config block + backend. Declaring it in both the module and the generated root would be a "Duplicate required providers" error at runtime. Also revert the earlier init lock-cleanup: the CI failure was stale provider references in state (fixed with `tofu state replace-provider`), not the lock.
35 lines
1.1 KiB
Makefile
35 lines
1.1 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:
|
|
@$(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
|