This repository has been archived on 2026-11-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
terraform-vault/Makefile
T
unkin-agent b9ae4a6802
ci/woodpecker/push/apply Pipeline failed
Add GitHub Actions JWT auth mount for IUCLabs (#175)
IUCLabs GitHub Actions workflows need read access to their own KV secrets without per-repo role and policy plumbing.

- add `auth/jwt/github/iuclabs` JWT mount trusting GitHub Actions OIDC
- add org-wide `default` role (mount `default_role`): audience `https://vault.service.consul:8200`, `user_claim=jti`, metadata mappings, 15m/1h TTLs
- restrict to `repository_owner=IUCLabs`, events push/release/schedule/pull_request, refs heads/tags/pull-merge; validation rejects anything wider
- attach templated read-only policy on `kv/github/<repo>/event/<event>/*` and `kv/github/<repo>/ref/<ref>/.secrets/*`
- add `tofu test` cases, run by `make test` and pre-commit
- document login, KV layout, event-path scope, `+` ref caveat and entity growth

Pairs with the terraform-git ref-name ruleset.

Reviewed-on: #175
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-11-10 23:25:31 +11:00

40 lines
1.4 KiB
Makefile

.PHONY: init plan apply format test
VAULT_AUTH_METHOD ?= approle
VAULT_K8S_ROLE ?= woodpecker_terraform_vault
VAULT_K8S_MOUNT ?= auth/k8s/au/syd1
VAULT_K8S_JWT_PATH ?= /var/run/secrets/kubernetes.io/serviceaccount/token
# Define vault_env function to set up vault environment
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-vault)
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 -- -lock=false
apply: init
@$(call vault_env) && \
terragrunt run --all --parallelism 2 --non-interactive apply
test:
@uv run --with pyyaml --with pydantic python -m unittest discover -s tests -t .
@cd modules/vault_cluster/modules/auth_jwt_role && tofu init -backend=false -input=false >/dev/null && tofu test
format:
@echo "Formatting OpenTofu files..."
@tofu fmt -recursive .
@echo "Formatting Terragrunt files..."
@terragrunt hcl fmt