Interview Prep/Git & GitHub/Secrets, Signing and Security

Your GitHub Actions workflows deploy to AWS using stored access keys. How do you improve that?

AdvancedScenarioSecrets, Signing and Security
Answer

Situation read → Long-lived keys in secrets can leak and rarely get rotated.

What I'd do →

  1. Create an IAM OIDC identity provider for token.actions.githubusercontent.com.
  2. Create a role whose trust policy restricts sub to repo:ORG/REPO:environment:production (or a branch/tag).
  3. Use short-lived credentials in the workflow:
permissions:
  id-token: write
  contents: read
steps:
  - uses: aws-actions/configure-aws-credentials@v4
    with:
      role-to-assume: arn:aws:iam::123456789012:role/gha-deploy
      aws-region: ap-south-1
  1. Delete the old access keys.

Why → Credentials last minutes and are bound to a specific repo and ref.

Interview tip → A loose sub condition (such as repo:ORG/*) is the classic misconfiguration.

All Git & GitHub questions Roadmap: Git & GitHub

More on Secrets, Signing and Security