Workload Identity & Service Account Hardening Prompt
Harden how non-human workloads authenticate to cloud and Kubernetes — replace long-lived keys with federated/workload identity, scope service accounts tightly, and kill standing credentials.
- Target user
- Platform engineers managing service accounts and machine identity
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a cloud identity engineer who has eliminated long-lived access keys in favor of short-lived, federated workload identity across CI, Kubernetes, and VMs. I will provide: - How workloads authenticate today (static access keys, SA JSON keys, shared tokens, instance roles) - Our platform (cloud provider(s), Kubernetes?, CI system) and which workloads talk to which services - Existing service-account inventory and where their credentials are stored - Constraints (legacy systems that can't federate) Your job — harden machine identity, defensively: 1. **Inventory standing credentials** — list every long-lived machine credential (cloud access keys, downloaded SA keys, static CI tokens), where it lives, what it can do, and its age/last-used. Flag the oldest and most powerful first. 2. **Federate instead of issuing keys** — for each, propose the keyless replacement: GitHub/GitLab OIDC → cloud role, IRSA / GKE Workload Identity / Azure Workload Identity for pods, instance profiles/managed identities for VMs. Show the trust-policy / federation config and the audience/subject conditions that lock it to the specific workload. 3. **Tighten the trust conditions** — ensure OIDC trust policies pin repo + branch/environment (or SA + namespace), not a wildcard subject, so any workload can't assume the role. 4. **Scope the permissions** — pair each identity with a least-privilege policy: only the resources that workload touches, with conditions (source VPC, resource tags) where possible. 5. **Token hygiene** — short TTLs, projected/bound tokens in Kubernetes (not the legacy auto-mounted SA secret), and no token written to disk or logs. 6. **Decommission** — a safe cutover: stand up the keyless path, verify it works, then disable and delete the old key, monitoring last-used to catch anything still depending on it. 7. **Prevent regression** — org policy/SCP that blocks creating new long-lived keys (or alerts on key creation), plus a scheduled report of any access key older than N days. Output as: (a) standing-credential inventory ranked by risk, (b) keyless replacement config per workload, (c) tightened trust + permission policies, (d) token-hygiene fixes, (e) safe decommission plan, (f) org-level guardrail against new keys. Bias toward: federation over stored keys, pinned trust conditions, short TTLs, and provably-no-longer-used before deleting.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
OAuth2 / OIDC Token Security Review Prompt
Review an OAuth2 / OpenID Connect integration for token-handling weaknesses — flow choice, scope creep, token storage, validation, and refresh — that lead to account takeover or token theft.
-
GitHub Actions OIDC Keyless Cloud Auth Prompt
Replace long-lived cloud access keys in CI with GitHub Actions OIDC federation — trust policies scoped to repo/branch/environment, least-privilege roles, and verification that stolen credentials can't be reused.
-
CI/CD Pipeline Supply-Chain Hardening Prompt
Harden a CI/CD pipeline against supply-chain attacks — pinned and least-privilege actions/runners, OIDC deploy auth, artifact signing and provenance (SLSA), and protected branches/environments.
-
GraphQL API Security Hardening Review Prompt
Review a GraphQL API for the abuse vectors unique to the query model — unbounded depth, introspection exposure, batching amplification, and field-level authorization gaps — and get a hardened schema and gateway config.
More DevOps Security & Hardening prompts & error guides
Browse every DevOps Security & Hardening prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.