Pipeline needs AWS access without storing access keys in GitHub.
IntermediateScenarioSecrets Provisioners and Policy as Code
Answer
Situation read → Long-lived keys in CI secrets are a liability.
What I'd do →
- Create an IAM OIDC identity provider for
token.actions.githubusercontent.com. - Create a role whose trust policy restricts
subtorepo:acme/infra:ref:refs/heads/main. - Use
aws-actions/configure-aws-credentialswithrole-to-assume.
permissions:
id-token: write
contents: read
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::123456789012:role/gha-terraform-apply
aws-region: ap-south-1
Why → Tokens are short-lived and bound to repo and branch; nothing to leak or rotate.
Interview tip → Always constrain the sub claim, or any repo could assume the role.
More on Secrets Provisioners and Policy as Code
A developer hardcodes a DB password in `terraform.tfvars` and commits it. What do you do right now, and what's the long-term fix?BeginnerHow do you avoid Terraform persisting a secret in state when creating a secret in AWS Secrets Manager?AdvancedSomeone wants a `remote-exec` provisioner to configure servers after creation. What's your advice?BeginnerYou must run a one-off command after a resource is created, such as registering with an external system.IntermediateHow do you generate and manage the master password for a new RDS instance?IntermediateCompare Sentinel, OPA/Conftest and Checkov for policy as code.Intermediate