This example provisions:
- A GitHub OIDC identity provider in your AWS account.
- Two IAM roles trusted by that provider:
org-infra-main— full Administrator access, only assumable from themainbranch oforganization/infrastructure. Also assumable by an SSO role for local debugging.org-infra-all-branches—AmazonS3ReadOnlyAccess, assumable from any branch of the same repo.
- Terraform
>= 1.5.7 - AWS credentials with permission to manage IAM and OIDC providers (e.g. via
aws-sso-cliorAWS_PROFILE) - Update
provider "aws"inmain.tfwith the region you want the roles created in. - Replace
organization/infrastructurewith your ownorg/repoand the placeholder SSO role with one from your account.
terraform init
terraform plan
terraform applyterraform destroySee the root README for the full input reference, the GitHub Actions workflow snippet, the subject-string cheat sheet, and troubleshooting.