Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Use GitHub Actions OpenID Connect (OIDC) to exchange a short-lived GitHub job token for temporary AWS credentials—no long-lived AWS access keys need to be stored in GitHub secrets. The setup has three parts: GitHub issues an identity token, an AWS IAM role trusts only the intended GitHub context, and AWS Security Token Service (STS) issues credentials when the token meets that role’s trust policy.

How GitHub Actions OIDC authentication works

  1. GitHub issues a job identity token. The workflow or job must have id-token: write permission to request an OIDC token. This permission enables token retrieval; it does not grant access to AWS resources. As GitHub Docs explains, setting it “does not give the workflow permission to modify or write to any resources.” See GitHub’s AWS OIDC configuration guide and its OIDC reference.
  2. AWS evaluates the token against the role’s trust policy. The policy should require the expected audience and limit the subject to the repository and branch, tag, or GitHub environment that is allowed to deploy.
  3. STS returns temporary credentials. The workflow’s AWS credentials action requests the role, and AWS STS issues credentials only if the token satisfies the trust policy. The assumed role’s permissions policy separately determines what those credentials can do.

Configure the AWS identity provider and role

Register GitHub as an OIDC provider

In AWS IAM, add an OpenID Connect identity provider with the provider URL https://token.actions.githubusercontent.com. For the official AWS credentials action, use sts.amazonaws.com as the audience. AWS’s guide to creating a role for OIDC federation describes the IAM setup.

Set a narrow role trust policy

Create or select an IAM role trusted by that provider. In its trust policy, require token.actions.githubusercontent.com:aud to equal sts.amazonaws.com and constrain token.actions.githubusercontent.com:sub to the intended repository context. AWS says a GitHub-trusting role should include a subject condition and that the subject must not be solely a wildcard; limit access to specific repositories or branches wherever possible.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a branch or tag, a conventional subject has a form such as repo:ORG/REPO:ref:refs/heads/BRANCH. Replace the example components with the exact organization, repository, and ref. Avoid broad patterns that would let unrelated branches or repositories assume the role.

#1 Best Overall
Yubico - Security Key C NFC - Basic Compatibility - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key C NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key C NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key C NFC via USB-C and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.

Match the subject format the repository actually emits

Do not assume every repository uses the same subject format. GitHub Docs says repositories created after July 15, 2026, or repositories opted into immutable subject claims, include immutable owner and repository IDs in the sub claim. Check the repository’s emitted OIDC subject and write the trust condition to match it; an older name-only example may not match. The date is a signal to verify, not a substitute for checking the repository’s configuration.

Choose a GitHub environment when deployment controls call for one

If the job references a GitHub environment, its subject identifies that environment, for example repo:ORG/REPO:environment:prod, rather than a branch or tag ref. Configure environment protection rules appropriate to the release process so the environment itself limits which deployments can proceed. Use the subject shape GitHub emits for that job.

Rank #2
SafeNet IDProve 700 OTP Card for use with Amazon Web Services Only
  • OTP Token in card format that provides secure remote access with strong authentication
  • Easy to use and easy to carry, same size as a credit card
  • Zero footprint; No software on end-user PCs
  • Compliant to OATH open standard (time based - 6 digits)
  • Expected battery life is 3 years or approximately 15,000 clicks

Give the role only the AWS permissions the deployment needs

The role’s trust policy and permissions policy answer different questions. The trust policy controls who may assume the role; the permissions policy controls what the assumed role may do. Attach only the AWS actions and resources required for the deployment. For example, a workflow that publishes files to one S3 bucket should not receive unrelated AWS permissions or unrestricted access to other buckets.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure the GitHub Actions workflow

Add OIDC permission at the workflow or job level, then use aws-actions/configure-aws-credentials to exchange the GitHub token for credentials for the IAM role. The following illustrates the shape; replace the role, account, region, bucket, and action revision with values you have verified for your setup.

Rank #3
Sale
Thetis Nano-A FIDO2 Security Key Hardware Passkey Device with USB Type A, TOTP/HOTP, FIDO2.0 Two Factor Authentication 2FA MFA, Works with Windows/mac/iOS/Android/Linux/Gmail/Facebook/GitHub/Coinbase
  • Ultra-Compact FIDO2 Security Key - Plug-and-stay or carry on a keychain. This USB-A hardware security key offers portable, always-on protection for desktop and mobile use. (Item Size: 0.75 X 0.74 IN x 0.25 IN)
  • USB-A Hardware Key for All Devices - Works with USB-A ports on PC, Mac, Android, and other laptop/notebook device. Enables secure, cross-platform login with FIDO2.0 passkey support.
  • FIDO Certified Security Key - Meets FIDO and FIDO2 standards. Works with Google, Microsoft, GitHub, Dropbox, and more. Please check service compatibility before purchase.
  • Passwordless Login with Passkey - Supports passkey login via WebAuthn and CTAP2. Enjoy password-free sign-ins where supported. Not all websites or services currently support passkeys.
  • Advanced Multi-Factor Authentication - Offers 200 FIDO2 passkey slots and 50 OATH-TOTP slots. Strong, flexible 2FA/MFA support across various apps and authentication platforms.
permissions:
  id-token: write
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: aws-actions/configure-aws-credentials@<reviewed-commit-sha>
        with:
          role-to-assume: arn:aws:iam::<account-id>:role/<deployment-role>
          aws-region: <region>
      - run: aws s3 cp ./site s3://<bucket>/ --recursive

contents: read is commonly needed when the workflow checks out repository code. Keep permissions no broader than the job requires. Review and pin the credentials action according to your repository’s action-security policy; GitHub’s example uses a full commit SHA. Check the current GitHub setup guidance and the action’s own documentation before adapting the example.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose the right trust boundary

  • Branch or tag: Use an exact subject for the repository and deployment ref when the role should be assumable only from that ref.
  • Environment: Use an environment subject when deployment eligibility is managed through a GitHub environment, and enforce the release process with environment protection rules.
  • Immutable subject claims: Match the subject format currently emitted by the repository, including immutable IDs when applicable.

In every case, pair the subject restriction with the audience condition and keep the role’s AWS permissions least-privilege. AWS does not support custom claims for GitHub OIDC trust; build conditions from supported claims and AWS IAM condition keys, as noted in GitHub’s AWS-specific OIDC guide.

Quick Recap

Bestseller No. 2
SafeNet IDProve 700 OTP Card for use with Amazon Web Services Only
SafeNet IDProve 700 OTP Card for use with Amazon Web Services Only
OTP Token in card format that provides secure remote access with strong authentication; Easy to use and easy to carry, same size as a credit card
$23.99
Bestseller No. 4
XCHTX 2PK Magnetic Key for Anti-Theft Security Slatwall&Peg Hook Magnet Key
XCHTX 2PK Magnetic Key for Anti-Theft Security Slatwall&Peg Hook Magnet Key
Feature: Material is four strong magnets in white plastic house
$16.68
Bestseller No. 5
FIDO2 U2F Security Key Passkey Two-Factor Authentication (2FA) USB Key PIN+Touch (Non-Biometric) USB-A Type TrustKey T110
FIDO2 U2F Security Key Passkey Two-Factor Authentication (2FA) USB Key PIN+Touch (Non-Biometric) USB-A Type TrustKey T110
For the driver download and user guide, please visit TrustKey Solutions Home support page.
$18.00
Best Value
FIDO2 U2F Security Key Passkey Two-Factor Authentication (2FA) USB Key PIN+Touch (Non-Biometric) USB-A Type TrustKey T110
  • Security Key : Protect your online accounts against unauthorized access by using FIDO2 and U2F authentication with T110. It's the world's most protective security key that works with windows, Mac OS, Linux as well as Chrome, Firefox, Edge and many other major browsers.
  • Certified with the new FIDO2 standard, T110 provides the benefit of fast login and strong protection against phishing, account takeover as well as many other online attactks.
  • Works with : Bank of America, Github, Google, Microsoft, DUO, Twitter, Facebook, Dropbox, Apple, ebay, BINANCE, mor and more.
  • Fits USB-A port : Insert the T110 security key into the USB-A port of each service and log in conveniently with one touch
  • For the driver download and user guide, please visit TrustKey Solutions Home support page.
Rank #4
XCHTX 2PK Magnetic Key for Anti-Theft Security Slatwall&Peg Hook Magnet Key
  • Feature: Material is four strong magnets in white plastic house
  • Functions: It is used for displaying your stuffs so that it beautifies and saves your space while it prevents your retail items from missing.Key unlocks your hook lock as security magnetic key ,it meets many purposes.It is suitable for any specific security hook like 6"7"8"peg&slat wall hook& other usages.
  • To use:You put it on the correct position when two tabs are in line ,then you slide it, so you unlock articles
  • Warranty: Erase electronic data off most devices. SO BE CAREFUL PLACING OR STORING ELECTRONICS NEAR,To keep them away from your wallet avoid damaging your credit pinch fingers slamming together or grab up metallic objects

Check these details before troubleshooting

  • Role assumption is denied: Confirm the provider URL and audience, then compare the token’s actual sub with the role trust policy. A branch/ref subject and an environment subject are different contexts; immutable-subject repositories may also require a different value.
  • The job cannot request a token: Verify id-token: write is granted to the workflow or the specific job.
  • The role is assumed but an AWS operation fails: Review the role’s permissions policy and resource scope. OIDC trust allows assumption; it does not grant deployment permissions by itself.
  • Dependabot update jobs are involved: GitHub’s AWS guide says OIDC tokens requested for Dependabot update jobs have event_name set to dynamic. If your policy uses event-name conditions to restrict authorized workflow events, account for that value explicitly.
  • Action revision is being selected: Verify and pin a reviewed revision in line with your action security policy rather than relying on a floating reference.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.