teluzia.Cloud Engineer · Day 109
CHAPTER 16 · CI/CD AND AUTOMATED DEPLOYMENTS

OIDC authentication to AWS

4–5 hours including independent practice3 topics
LET’S MAKE THIS SIMPLE

What you’re learning today

OIDC exchanges a verified short-lived visitor badge for a limited AWS role session instead of storing a permanent master key. GitHub can issue an OIDC token to a job with id-token: write permission. The AWS role must trust the GitHub provider for sts:AssumeRoleWithWebIdentity. AWS credentials are a separate resulting session. Token-request permission itself grants no AWS resource actions. Limit trust by audience and exact expected subject. The audience commonly used by the official action is sts.amazonaws.com. Current GitHub documentation distinguishes older name-based subjects from immutable owner/repository-ID subjects used by repositories created after July 15, 2026 or opted in; match the actual repository format.

Think of it this way

OIDC exchanges a verified short-lived visitor badge for a limited AWS role session instead of storing a permanent master key.

TOPIC 01 / 03Step by step

Token issuance and role exchange

GitHub can issue an OIDC token to a job with id-token: write permission. The AWS role must trust the GitHub provider for sts:AssumeRoleWithWebIdentity. AWS credentials are a separate resulting session. Token-request permission itself grants no AWS resource actions. For example, a job requests a GitHub JWT, then a reviewed configure-aws-credentials action exchanges it for an AWS role session.

WORKED EXAMPLE
A job requests a GitHub JWT, then a reviewed configure-aws-credentials action exchanges it for an AWS role session.

A deployment job requests an OIDC token from GitHub because it has id-token: write permission. The configured AWS identity provider and role trust policy then determine whether AWS accepts that token for AssumeRoleWithWebIdentity. Successful exchange returns temporary role credentials, which the job uses for separately authorized AWS requests.

OIDC is a federation protocol carrying identity claims. A token is signed identity evidence. A role session is the resulting temporary AWS identity. The token-request permission does not grant S3, ECR, or cluster access by itself. Diagnose issuance, trust exchange, and later resource authorization as three distinct steps. Temporary credentials remove the need to store a permanent access key, but the assumed role may still be too powerful. Pin and review the credential-configuring action, scope its role, and verify account identity without printing the JWT or credential values into logs.

Why this matters

A job requests a GitHub JWT, then a reviewed configure-aws-credentials action exchanges it for an AWS role session.

A common trap

Do not overlook this operational distinction: Token-request permission itself grants no AWS resource actions.

Read all topics in this lesson

A complete reference to revisit alongside the guided steps above.

Token issuance and role exchange

GitHub can issue an OIDC token to a job with id-token: write permission. The AWS role must trust the GitHub provider for sts:AssumeRoleWithWebIdentity. AWS credentials are a separate resulting session. Token-request permission itself grants no AWS resource actions. For example, a job requests a GitHub JWT, then a reviewed configure-aws-credentials action exchanges it for an AWS role session.

WORKED EXAMPLE
A job requests a GitHub JWT, then a reviewed configure-aws-credentials action exchanges it for an AWS role session.

A deployment job requests an OIDC token from GitHub because it has id-token: write permission. The configured AWS identity provider and role trust policy then determine whether AWS accepts that token for AssumeRoleWithWebIdentity. Successful exchange returns temporary role credentials, which the job uses for separately authorized AWS requests.

OIDC is a federation protocol carrying identity claims. A token is signed identity evidence. A role session is the resulting temporary AWS identity. The token-request permission does not grant S3, ECR, or cluster access by itself. Diagnose issuance, trust exchange, and later resource authorization as three distinct steps. Temporary credentials remove the need to store a permanent access key, but the assumed role may still be too powerful. Pin and review the credential-configuring action, scope its role, and verify account identity without printing the JWT or credential values into logs.

Why this matters

A job requests a GitHub JWT, then a reviewed configure-aws-credentials action exchanges it for an AWS role session.

A common trap

Do not overlook this operational distinction: Token-request permission itself grants no AWS resource actions.

Audience and subject trust

Limit trust by audience and exact expected subject. The audience commonly used by the official action is sts.amazonaws.com. Current GitHub documentation distinguishes older name-based subjects from immutable owner/repository-ID subjects used by repositories created after July 15, 2026 or opted in; match the actual repository format. For example, a new immutable subject can be repo:org@123/repo@456:ref:refs/heads/main; a legacy repository may still use repo:org/repo:ref:refs/heads/main.

WORKED EXAMPLE
A new immutable subject can be repo:org@123/repo@456:ref:refs/heads/main; a legacy repository may still use repo:org/repo:ref:refs/heads/main.

AWS receives a GitHub token containing an audience and subject. The trust policy should accept the intended audience and the exact authorized repository context. Current GitHub guidance distinguishes legacy name-based subjects from immutable owner/repository-ID subjects for newly created or opted-in repositories. Obtain the actual format for the repository rather than copy an older sample blindly.

Audience identifies the intended token recipient. Subject identifies the workload context. Immutable identifiers reduce reliance on renameable account or repository names. The commonly used AWS audience is sts.amazonaws.com for the official credential action. A branch subject and an environment subject represent different contexts. An overly broad wildcard can admit unintended branches or repositories; a too-narrow stale string can deny the legitimate release. Test the intended allowed and denied contexts, preserve exact spelling and ID representation, and check official documentation when repository settings or claim customization change.

Why this matters

A new immutable subject can be repo:org@123/repo@456:ref:refs/heads/main; a legacy repository may still use repo:org/repo:ref:refs/heads/main.

A common trap

Do not overlook this operational distinction: Current GitHub documentation distinguishes older name-based subjects from immutable owner/repository-ID subjects used by repositories created after July 15, 2026 or opted in; match the actual repository format.

Environment subjects and session permissions

Jobs using environments have environment-form subjects, so a branch-only trust condition may not match. Configure corresponding environment protections and check actual immutable-subject behavior when applicable. The role permission policy still limits AWS actions after successful assumption; authentication does not make the session an administrator. For example, a production environment job uses the expected environment subject and a role scoped to one release repository, not all AWS services.

WORKED EXAMPLE
A production environment job uses the expected environment subject and a role scoped to one release repository, not all AWS services.

A production job uses an environment and requests AWS credentials. Its token subject must match the environment-form context and applicable repository subject format. After assumption, its AWS permission policy limits actions to the intended release repository or cluster operation. Environment protections and AWS authorization cooperate but are not the same control.

A trust condition limits who can obtain the role session. A permission policy limits what that session may do. An environment gate limits when GitHub permits the deployment job to proceed. Restrict eligible branches and configure actual protections rather than assume the environment name proves approval. If STS succeeds but an ECR push fails, inspect role actions and repository permissions instead of widening trust. If STS fails, inspect actual claims and provider configuration. These separated diagnostics preserve least privilege and avoid fixing one context mismatch by allowing every repository to assume a powerful role.

Why this matters

A production environment job uses the expected environment subject and a role scoped to one release repository, not all AWS services.

A common trap

Do not overlook this operational distinction: The role permission policy still limits AWS actions after successful assumption; authentication does not make the session an administrator.

KEEP THESE WITH YOU

Today’s takeaways

Token issuance and role exchange: GitHub can issue an OIDC token to a job with id-token: write permission. The AWS role must trust the GitHub provider for sts:AssumeRoleWithWebIdentity. AWS credentials are a separate resulting session. Token-request permission itself grants no AWS resource actions.

Audience and subject trust: Limit trust by audience and exact expected subject. The audience commonly used by the official action is sts.amazonaws.com. Current GitHub documentation distinguishes older name-based subjects from immutable owner/repository-ID subjects used by repositories created after July 15, 2026 or opted in; match the actual repository format.

Environment subjects and session permissions: Jobs using environments have environment-form subjects, so a branch-only trust condition may not match. Configure corresponding environment protections and check actual immutable-subject behavior when applicable. The role permission policy still limits AWS actions after successful assumption; authentication does not make the session an administrator.

CLOSE THE LOOP

Ready to complete this day?

Verify the practical steps and pass the knowledge check (at least two thirds correct).

Lab steps verifiedKnowledge check passed