The problem

Every long-lived AWS credential sitting in a CI secrets vault is a standing risk — not because the vault is weak, but because a credential that never expires is a credential that, if it ever leaks, works forever until someone notices and rotates it manually.

Most "fix" that risk by rotating the key more often. That's treating the symptom. The actual fix is to remove the static credential entirely.

What this module does

This Terraform module replaces static AWS access keys in GitHub Actions with OIDC federation:

  • GitHub Actions issues a short-lived OIDC token for the workflow run.
  • AWS exchanges that token for a temporary IAM role session — scoped to the specific repository and branch via the role's trust policy.
  • There is no static key to rotate, because there is no static key to leak in the first place.
  • The temporary session expires automatically; no manual cleanup, no secret rotation schedule to maintain.

What's actually in the repo

  • A complete Terraform module (main.tf, variables.tf, outputs.tf, versions.tf) — not a snippet, something you can plan/apply.
  • A GitHub Actions CI workflow that validates the module itself on every push: terraform fmt, terraform validate, tflint, and checkov — all static analysis, no AWS account needed to verify the module is sound.
  • Three Mermaid diagrams in the README: the architecture, a before/after comparison, and a sequence diagram of the actual OIDC handshake.

A real lint finding, not just a clean first pass

tflint caught an actually unused data "aws_caller_identity" block left over from an earlier draft — removed before the first green CI run. Small, but it's the kind of thing that's easy to miss by eye and exactly what static analysis in CI is for.

Stack

Terraform, AWS IAM, GitHub Actions.

If your pipeline still has an AWS_SECRET_ACCESS_KEY sitting in a GitHub secret right now, this is the pattern that removes it for good.

Repo: https://github.com/Athilaf/aws-github-oidc-keyless-auth