Design access for a CI pipeline in GitHub Actions to deploy to AWS without storing AWS keys in GitHub.
IntermediateScenarioIAM, Organizations and Multi-Account
Answer
Situation read → OIDC federation lets GitHub present a signed token that AWS exchanges for temporary role credentials.
What I'd do →
- Create an IAM OIDC provider for
token.actions.githubusercontent.comwith audiencests.amazonaws.com - Create a deploy role whose trust policy uses
sts:AssumeRoleWithWebIdentityand a conditiontoken.actions.githubusercontent.com:subequal torepo:acme/shop:ref:refs/heads/main - In the workflow set
permissions: id-token: writeand useaws-actions/configure-aws-credentialswithrole-to-assume - Scope the role policy to only the resources it deploys
Why → No secret exists to steal, tokens last about an hour, and the sub condition ties the role to one repo and branch.
Interview tip → Call out that a missing sub condition lets any repo on GitHub assume the role.
More on IAM, Organizations and Multi-Account
A developer needs read-only access to one S3 bucket from their laptop. How do you grant it without creating long-lived access keys?BeginnerAn EC2 application needs to write to DynamoDB. Where do the credentials come from?BeginnerSecurity wants to know who deleted a production S3 bucket yesterday. How do you find out?BeginnerYou must stop anyone in a member account from disabling CloudTrail, even account admins. What do you use?BeginnerA cross-account role assumption fails with AccessDenied even though the target role trusts the source account. What do you check?IntermediateHow would you let developers create IAM roles for their apps without letting them escalate to admin?Intermediate