PR workflows need read-only AWS access for `terraform plan`, including from same-repo branches. How do you set trust?
AdvancedScenarioSecrets, OIDC & Environments
Answer
Situation read → Separate low-privilege role for PRs.
What I'd do →
- Role
tf-plan-readonlywithReadOnlyAccessplus state bucket read and lock table access. - Trust
sub=repo:devopsshack/infra:pull_request. - Fork PRs do not get the OIDC token with secrets context in a usable way; keep plans for forks disabled or manual.
Why → PR code is less trusted, so its identity gets read-only permissions, while apply uses a different environment-pinned role.
Interview tip → Two roles, two trust subjects: one for PRs, one for the gated apply.
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.BeginnerWrite the AWS trust policy for a role used only by the prod deploy job of one repo.IntermediateA team stores a 200 KB kubeconfig and certificates as secrets and hits the size limit. What do you recommend?Intermediate