agentleFS
mchittinenimchittineni/cloud-platform-skills/.cursor/rules/skills/secrets-management-vault-kms.mdc

cloud-platform-skills / skills

Cursor rule1 starsChanged 4 months agoMITView on GitHub

Secrets management with HashiCorp Vault, External Secrets Operator, and cloud KMS: dynamic short-lived credentials, envelope encryption, Kubernetes auth and workload identity, automatic rotation on a schedule instead of manual 90-day resets, and revocation under compromise. Use when a database password or API key sits in a plain Kubernetes Secret or a manifest checked into Git, or when workloads need credential material injected at runtime without storing it.

The file

We split this secrets-management-vault-kms.mdc into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Workload identity replaces the first secret: Every secrets architecture bottoms out in one question: how does the workload prove who it is …

    line 73

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
secrets-management-vault-kms.mdc
---
description: "Secrets management with HashiCorp Vault, External Secrets Operator, and cloud KMS: dynamic short-lived credentials, envelope encryption, Kubernetes auth and workload identity, automatic rotation on a schedule instead of manual 90-day resets, and revocation under compromise. Use when a database password or API key sits in a plain Kubernetes Secret or a manifest checked into Git, or when workloads need credential material injected at runtime without storing it."
globs:
alwaysApply: false
---

# Secrets Management with HashiCorp Vault & External Secrets Operator

## When to Use This Skill

**Triggers — load this skill when:**

- Static long-lived credentials must be replaced with dynamic or short-lived ones
- Kubernetes workloads need secrets injected without committing them to Git
- A rotation policy or a leaked-credential response is being designed

**Route elsewhere when:**

- Detecting committed secrets in code -> `shift-left-security-sast-sca`
- Cloud IAM trust policy and federation design -> `aws-iam-zero-trust-policies`

## 1. External Secrets Operator (ESO) Pattern in Kubernetes

```yaml
apiVersion: external-secrets.io/v1beta1
kind: SecretStore
metadata:
  name: vault-backend
  namespace: production
spec:
  provider:
    vault:
      server: "https://vault.internal.corp:8200"
      path: "secret"
      version: "v2"
      auth:
        kubernetes:
          mountPath: "kubernetes"
          role: "payment-service-role"
---
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
  name: payment-db-credentials
  namespace: production
spec:
  refreshInterval: "1h"
  secretStoreRef:
    name: vault-backend
    kind: SecretStore
  target:
    name: db-credentials-k8s-secret
    creationPolicy: Owner
  data:
    - secretKey: DB_PASSWORD
      remoteRef:
        key: database/production/payment
        property: password
```

---

## 2. Secrets Management Principles

- **No Secrets in Git**: Enforce zero plain-text secrets in repository commits, even in private repositories.
- **Dynamic & Short-Lived Credentials**: Leverage Vault database engines to issue just-in-time PostgreSQL/MySQL credentials with 1-hour TTLs.
- **Envelope Encryption**: Encrypt sensitive data keys using Cloud KMS (AWS KMS, Azure Key Vault, GCP KMS) Customer Managed Keys (CMKs).

---

## 3. Workload Identity & Revocation

**Workload identity replaces the first secret.** Every secrets architecture bottoms out in one
question: how does the workload prove who it is without a pre-shared credential? Use the
platform's attested identity, never a bootstrap token in an image:

| Platform | Attested identity | Vault / cloud binding |
| --- | --- | --- |
| Kubernetes | Projected ServiceAccount token (OIDC) | Vault `kubernetes` auth role bound to SA + namespace |
| EKS | IRSA / Pod Identity | IAM role trust on the OIDC subject |
| AKS | Entra Workload Identity | Federated credential on the SA subject |
| GKE | Workload Identity | KSA→GSA binding |
| CI (GitHub/GitLab) | OIDC job token | Role trust conditioned on repo + ref + environment |

```yaml
# Vault Kubernetes auth role — identity is the namespace + service account, not a token
path "auth/kubernetes/role/payments" {
  bound_service_account_names      = ["payments"]
  bound_service_account_namespaces = ["prod-payments"]
  token_ttl                        = "20m"      # short TTL is the point
  token_policies                   = ["payments-read"]
}
```

**Revocation is the control that matters under compromise.** Design for it before the incident:

```bash
vault lease revoke -prefix database/creds/payments   # kill every dynamic credential at once
vault token revoke -accessor <accessor>              # kill one workload's session
aws iam update-access-key --status Inactive --access-key-id AKIA...   # static key: disable, then delete
```

Rotate on a schedule **and** on every role change or team departure; a rotation procedure that
has never been executed under time pressure is not yet a control. Static secrets that cannot be
made dynamic get a documented owner, a maximum age, and an alert when that age is exceeded.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.