Each environment should deploy to a different AWS account. How do you structure roles and variables?
AdvancedScenarioSecrets, OIDC & Environments
Answer
Situation read → Multi-account with OIDC.
What I'd do →
- OIDC provider in each account (dev, staging, prod), created by Terraform.
- Role per account trusting
repo:ORG/REPO:environment:<env>. - Environment variable
DEPLOY_ROLE_ARNper environment,AWS_REGIONas repo variable. - Same workflow,
role-to-assume: ${{ vars.DEPLOY_ROLE_ARN }}.
Why → Account boundaries plus environment-pinned trust contain any compromise to one stage.
Interview tip → Mention that role ARNs are config (variables), not secrets.
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.IntermediatePR workflows need read-only AWS access for `terraform plan`, including from same-repo branches. How do you set trust?Advanced