AWS Builder Center

Short-lived credentials on AWS: a practical guide for startups

A leaked key you still depend on can become an outage. A guide to IAM credential reports, GitHub OIDC, Roles Anywhere, Secrets Manager and GuardDuty.


It's Monday morning. Transactional emails stopped going out over the weekend, SMS verification is failing, and inference calls return 401s. Nobody deployed anything. The cause is a key a contractor committed to a public repo eighteen months ago. Someone finally revoked it, and production depended on it.
For years, a leaked secret was a risk you could leave in the backlog because nothing broke until an attacker found it. Issuers are now starting to revoke leaked keys on their own.

What changed

On November 5, 2026, Truffle Security launched the free Secrets Revocation Program, which helps API key issuers revoke around 1.4 million publicly exposed secrets that still work ( BleepingComputer ). Truffle finds keys in public repositories, packages, container images, datasets and applications, and verifies them with TruffleHog. Issuers either expose a revocation endpoint, or receive verified keys through a webhook and revoke them within 14 days.
Truffle started the program because notifying owners isn't enough. It reports that 81% of the keys it reported last year still worked six months later. When Google moved from notifying owners to automatically disabling leaked service-account keys in June 2024, the share still active fell from 72% to 11%.
Sixteen issuers joined at launch, including Hugging Face, Notion, Vercel, Resend, RubyGems and Twilio. AWS isn't on the list, but it already acts on its side: when it detects publicly exposed IAM user access keys, it can attach the AWSCompromisedKeyQuarantineV3 managed policy, which denies certain actions to limit abuse ( AWS docs ). This is good for the ecosystem, but if your production still depends on long-lived keys, a revocation can take it down.

Why it matters for startups

Long-lived credentials pile up fast:
  • an IAM user created for the first CI pipeline, still there three years later;
  • a payment-provider key pasted into a .env file "just for now";
  • a token in an AI coding assistant's config file. Truffle has found 2,655 working keys in such files since January 2025.

Nobody owns these keys, and none of them expire. Once one leaks, either an attacker uses it or the issuer revokes it. Revocation is becoming the more likely outcome, and if that key runs production, you get an unplanned outage.
The way out is to stop depending on secrets that live forever. Use roles and temporary credentials wherever you can, and managed, rotated storage for the static keys you can't avoid.

Step by step: getting rid of long-lived keys

1. Inventory what you have

  • The IAM credential report (aws iam generate-credential-report) lists every IAM user's access keys with status, age and last-used date. Flag keys older than 90 days and active keys nobody uses.
  • An IAM Access Analyzer unused access analyzer continuously reports unused roles, access keys and passwords, plus unused permissions on active principals ( AWS docs ). It's a paid feature, so check pricing first.
  • Any IAM user with an AWSCompromisedKeyQuarantine policy attached has a key that AWS has already detected as exposed.
Deactivate unused keys, watch for a week, then delete them.

2. Replace CI keys with GitHub OIDC and IAM roles

CI pipelines usually hold the most long-lived keys, and they are the easiest to fix. First, register GitHub's identity provider:
$ aws iam create-open-id-connect-provider \
--url https://token.actions.githubusercontent.com \
--client-id-list sts.amazonaws.com

Then create a role whose trust policy only allows one repository and branch. A wildcard on the whole org is a common mistake.
{
"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",
"token.actions.githubusercontent.com:sub": "repo:your-org@1234567/your-repo@89012345:ref:refs/heads/main"
}
}
}]
}


Check the sub format before you copy it. Since July 15, 2026, GitHub appends immutable owner and repository IDs for new, renamed or transferred repositories ( GitHub changelog ). Older repositories keep repo:your-org/your-repo:... unless you opt in. Opting in is worth it, because a recycled org or repo name can then no longer inherit your AWS trust. Deployments through GitHub environments end with environment:<name> instead of the branch ref.

In the workflow:
permissions:
id-token: write # needed to request the OIDC token
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::123456789012:role/github-deploy-main
role-session-name: gh-${{ github.run_id }}
aws-region: eu-west-3
- run: aws sts get-caller-identity
Naming the session after the run ID lets you trace each run in CloudTrail. Once the workflow works, delete the old AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY repository secrets and deactivate the IAM user's keys. Each job now gets credentials that expire after about an hour. GitLab, Bitbucket and most other CI providers support the same pattern.

3. Use IAM Roles Anywhere for on-prem and hybrid workloads

Long-lived keys tend to survive longest on workloads outside AWS, like a GPU box in a colo or an on-prem data pipeline. IAM Roles Anywhere lets those workloads exchange an X.509 certificate for temporary credentials, through a trust anchor tied to AWS Private CA or your own PKI.
Since November 5, 2026, it can check revocation automatically using CRL distribution points ( AWS What's New ). Once you enable this on a trust anchor, Roles Anywhere reads the CDP URLs in authenticating certificates, downloads the CRLs and refreshes them periodically, and denies requests that use revoked certificates. You no longer have to re-import CRLs by hand each time your CA publishes one. Certificates need publicly accessible CDP URLs, and the feature costs nothing extra in all commercial Regions.
Revoking a compromised machine's certificate at your CA now also cuts off its AWS access.

4. Store third-party API keys in Secrets Manager with rotation

Twilio, Stripe, model providers and email APIs all hand you a static key. Those providers are the kind of issuer that revocation programs work with, and Twilio has already joined Truffle's.
  • Store these keys in AWS Secrets Manager and fetch them at runtime through an IAM role. Keep them out of images, env files and front-end bundles.
  • Rotate them with a Lambda function that creates a new key through the provider's API, updates the secret and revokes the old key. If the provider has no API for this, keep a short manual runbook.
  • Cache secrets with the AWS SDK or the Secrets Manager caching libraries, so your services pick up a rotated or replaced key without a redeploy.

5. Detect leaks and leaked-credential use

Turn on GitHub secret scanning and push protection, private repos included, and add a pre-commit hook such as TruffleHog or gitleaks. Add .env files and AI tool config files to .gitignore.
Enable Amazon GuardDuty in every account and Region. Its IAM finding types flag activity that suggests compromised credentials, and UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration detects EC2 instance credentials used from outside your environment ( GuardDuty docs ). Send high-severity findings to a channel someone watches, and keep the  remediation guide  at hand.

Where to start

Mass revocation shrinks the pool of stolen credentials attackers can use, and it also means a leaked key can cause an outage on someone else's schedule. Short-lived credentials expire on their own, so a leak gives an issuer nothing to revoke.
Two hours this week is enough to start:
  1. Pull your IAM credential report.
  1. Move one CI pipeline to OIDC.
  1. Move your most critical third-party API key into Secrets Manager.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article