Interview Prep/CI/CD/GitHub Actions

Your deploy job uses a long-lived AWS access key stored in repo secrets. How do you improve it?

IntermediateScenarioGitHub Actions
Answer

Situation read → Static cloud keys in CI.

What I'd do →

  1. Create an IAM OIDC identity provider for token.actions.githubusercontent.com and a role with a trust policy limited to repo:my-org/app:environment:production in the sub claim and aud of sts.amazonaws.com.
  2. In the workflow, set permissions: id-token: write and use aws-actions/configure-aws-credentials@v4 with role-to-assume.
  3. Delete the stored keys.

Why → OIDC yields short-lived credentials scoped to a repo, branch or environment, with nothing to leak.

Interview tip → A trust policy without a tight sub condition lets any repo assume the role.

All CI/CD questions

More on GitHub Actions