Federated CI identity and rollback
Temporary identity for CI
OpenID Connect (OIDC) lets a CI job present a signed identity token to AWS STS and obtain temporary role credentials. A role trust policy defines which identity can assume it; a separate permissions policy defines the allowed AWS actions. For GitHub Actions, grant id-token: write only to the job that needs federation; this permits requesting an OIDC token, not automatic AWS access. Never expose a production role to untrusted pull request code.
Restrict the production trust
The static example uses a fictional account and repository. It assumes an existing GitHub OIDC provider and the conventional subject format for a job targeting the production environment. Check actual token claims and repository subject configuration before deployment. Both audience and exact subject must match. Protect the GitHub environment with restricted branches and required reviewers where available: the environment subject alone does not establish a branch restriction. Separate test and production roles; scope cross-account artifact reads, KMS decryption where needed, and deployment actions to intended targets. Do not copy this example into a live account without review.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Federated": "arn:aws:iam::111122223333: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:example-org/example-app:environment:production" } } } ]}Release gradually and recover
Blue/green deployment prepares a separate replacement environment and shifts traffic; canary delivery starts with a small fraction of traffic before wider rollout. Both require health signals, an observation window and a stop condition. CodeDeploy rollout options depend on the target platform. Rollback can redeploy a last-known-good revision or restore traffic, but does not automatically undo database writes, external side effects or incompatible schema changes. Keep the prior digest available, verify schema compatibility, and rehearse recovery.
Practice: protect the release
A token from another repository has the correct audience but a different subject. Reject it. A canary fails its health threshold: stop expansion and select the prior approved digest only if recovery is compatible. A schema-breaking change needs a separate recovery decision. The offline checks model exact string matching and a fictional approval gate; they do not verify signatures, STS, IAM policy evaluation or actual deployment behavior.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Federated CI identity and rollback — knowledge check
Reason about a safe delivery pipeline using synthetic scenarios.
An OIDC token has the expected audience but a different repository subject. What should this trust policy do?
What does the role permissions policy determine?
Why protect the GitHub production environment?
A canary fails its health threshold. What is the next action?
What is not automatically undone by redeploying a previous application revision?