Writing

Short-Lived Credentials: Eliminating Long-Lived AWS Keys with GitHub OIDC

A practical blueprint for zero static secrets via cryptographic STS role federation.

Jun 18·4 min read·Cloud
Short-Lived Credentials: Eliminating Long-Lived AWS Keys with GitHub OIDC

“The safest secret is the one that ceases to exist fifteen minutes after creation.”

Long-lived AWS access keys stored in CI secrets are the single most common vector for cloud account compromise. By switching to OpenID Connect (OIDC) identity federation, we eliminated permanent secrets entirely.

The Danger of Static Access Keys

When engineers store AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY inside repository secrets, rotation is neglected and credentials persist indefinitely. If a pipeline is misconfigured or a third-party action is compromised, those credentials can be exfiltrated.

With OIDC federation, GitHub acts as an Identity Provider (IdP). AWS validates short-lived JSON Web Tokens (JWT) signed by GitHub's certificate authority, minting temporary STS credentials valid for only 15 to 60 minutes.

Trust Policy Condition Scoping

To prevent arbitrary repositories from assuming your roles, the IAM trust policy must strictly match both the GitHub organization and the target branch name:

iam/github-oidc-trust-policy.json
json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::123456789012:oidc-provider/token.actions.githubusercontent.com"
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringEquals": {
          "token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
        },
        "StringLike": {
          "token.actions.githubusercontent.com:sub": "repo:wvrner/*:ref:refs/heads/main"
        }
      }
    }
  ]
}

Zero Stored Secrets in CI

With this configuration, CI workflows request temporary credentials directly from AWS STS using standard GitHub action steps. No developer ever handles, copies, or rotates an AWS key again.

aws-actions/configure-aws-credentials

Configure AWS credential environment variables for use in other GitHub Actions.

TypeScript
3.0k
581

Selected Writing

See all writing →
Deterministic Cloud Invariants: Designing Ephemeral Environments with Zero State Drift

Deterministic Cloud Invariants: Designing Ephemeral Environments with Zero State Drift

A mathematical framework for cloud isolation and on-demand cluster lifecycles.

Oct 14·6 min read
Terraform
Zero-Downtime Rollouts: Statistical Canary Verification in Multi-Cluster Mesh

Zero-Downtime Rollouts: Statistical Canary Verification in Multi-Cluster Mesh

Automated traffic weighting and real-time Mann-Whitney U error budget analysis.

Aug 4·5 min read
Kubernetes
Telemetry Without Noise: High-Cardinality Distributed Tracing in Production

Telemetry Without Noise: High-Cardinality Distributed Tracing in Production

Linking anomalous metric spikes directly to contextual exemplar trace graphs.

Apr 22·7 min read
Networking
Zero-Overhead Kernel Introspection: Enforcing Security Invariants with eBPF and Cilium

Zero-Overhead Kernel Introspection: Enforcing Security Invariants with eBPF and Cilium

Replacing iptables connection bottlenecks with direct Linux kernel socket filtering.

Mar 15·8 min read
Kubernetes
Back to portfolio

Let’s talk.

[email protected]
Elsewhere
  • GitHubwvrner↗
  • LinkedInin/wvrner↗
  • Telegram@wvrner↗
  • WhatsApp+ Direct↗
WVRNER
© Nima HosseiniBack to top ↑