How do you use HashiCorp Vault with CI/CD?
AdvancedProductionSecrets and Credentials
Answer
Authenticate the pipeline to Vault with its identity instead of a stored token: GitHub OIDC (hashicorp/vault-action with method: jwt), GitLab id_tokens, or Kubernetes auth for in-cluster agents. A Vault role binds the JWT claims (repo, branch/environment) to a policy granting read access to only that application's path, with a short token TTL. Use dynamic secrets (database or cloud credentials generated per job and revoked after) where possible, so even a leaked value expires in minutes.
- uses: hashicorp/vault-action@v3
with:
url: https://vault.example.com
method: jwt
role: shop-api-ci
secrets: |
secret/data/ci/shop-api registry_token | REGISTRY_TOKEN
More on Secrets and Credentials
Why are long-lived credentials in CI a problem, and what is the modern alternative?BeginnerHow do you manage application secrets from build to runtime?IntermediateHow do you store secrets in Git safely for GitOps?IntermediateHow do you detect secrets committed to a repo?BeginnerWhat do you do after a secret is committed to Git?IntermediateHow do you rotate a credential used by dozens of pipelines without downtime?Advanced