Write the AWS trust policy for a role used only by the prod deploy job of one repo.
IntermediateScenarioSecrets, OIDC & Environments
Answer
Situation read → Pin issuer, audience and subject.
What I'd do →
- Trust policy:
{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Principal": { "Federated": "arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com" }, "Action": "sts:AssumeRoleWithWebIdentity", "Condition": { "StringEquals": { "token.actions.githubusercontent.com:aud": "sts.amazonaws.com", "token.actions.githubusercontent.com:sub": "repo:devopsshack/shack-api:environment:prod" } } }] } - Attach a policy allowing only what the deploy needs (for example
eks:DescribeCluster).
Why → Only jobs bound to the prod environment, which require approval, can assume it.
Interview tip → Explain that environment protection plus sub pinning chains GitHub approvals to AWS access.
More on Secrets, OIDC & Environments
You find AWS access keys stored as repo secrets in 25 repos. Plan the migration.IntermediateA developer asks to print a secret in the log "just once" to debug. What do you do instead?BeginnerStaging and prod need different database URLs and different AWS roles, using one workflow. How?BeginnerSecurity requires two people for prod deploys: the author cannot approve. Configure it.BeginnerPR workflows need read-only AWS access for `terraform plan`, including from same-repo branches. How do you set trust?AdvancedA team stores a 200 KB kubeconfig and certificates as secrets and hits the size limit. What do you recommend?Intermediate