Interview Prep/DevSecOps/Secrets and Identity Management

Your CI pipeline uses long-lived AWS access keys stored as repository secrets. How do you replace them?

IntermediateScenarioSecrets and Identity Management
Answer

Situation read → Static keys in CI are the most common cloud breach path. OIDC federation removes them completely.

What I'd do →

  1. Create a GitHub OIDC identity provider in IAM (token.actions.githubusercontent.com).
  2. Create a role whose trust policy restricts sub to the exact repo and branch or environment:
"Condition": {
  "StringEquals": { "token.actions.githubusercontent.com:aud": "sts.amazonaws.com" },
  "StringLike": { "token.actions.githubusercontent.com:sub": "repo:acme/orders:environment:prod" }
}
  1. In the workflow add permissions: id-token: write and use aws-actions/configure-aws-credentials with role-to-assume.
  2. Run both paths for a week, then delete the IAM user and its keys.

Why → Credentials now last about an hour, are scoped to one repo and environment, and nothing exists to leak.

Interview tip → Mention the sub condition; a wildcard repo:acme/* trust is a common mistake.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Secrets and Identity Management