Appearance
How to Set Up GitHub OIDC for AWS
GitHub OIDC lets GitHub Actions authenticate to AWS without storing any long-lived credentials — AWS issues a short-lived token at run time by trusting GitHub's identity provider.
Prerequisites
- An AWS account — see Creating AWS account if you haven't set one up yet
- Permissions to manage IAM (create identity providers and roles)
Step 1 of 3 — Add GitHub as an OIDC Identity Provider in AWS IAM
Sign in to the AWS Management Console.
Search for IAM in the top search bar and open it.
In the left sidebar, click Identity providers.
Click Add provider.
Select OpenID Connect.
Fill in:
Field Value Provider URL https://token.actions.githubusercontent.comAudience sts.amazonaws.comClick Get thumbprint, then click Add provider.
Note: You only need to do this once per AWS account — the same provider is reused for all repositories.
Step 2 of 3 — Create an IAM Role for GitHub Actions
In IAM, click Roles in the left sidebar.
Click Create role.
Under Trusted entity type, select Web identity.
Fill in:
Field Value Identity provider token.actions.githubusercontent.comAudience sts.amazonaws.comGitHub organisation Your GitHub org or username (e.g. my-org)GitHub repository (optional) Your repository name (e.g. ZBCorpArchitecture), or enter*to allow all repositories in the orgGitHub branch (optional) The branch to restrict access to (e.g. main), or enter*to allow all branchesClick Next.
Search for and select the following managed policies, then click Next:
Policy Used for AWSSSOMasterAccountAdministratorIAM Identity Center (SSO) — Entra integration (stages c20, c21) AWSOrganizationsFullAccessAWS Organizations access required by IAM Identity Center CloudFrontFullAccessCloudFront distributions (stage c25) AmazonS3FullAccessS3 origin bucket for CloudFront AmazonRoute53FullAccessDNS records for the custom domain AWSCertificateManagerFullAccessTLS certificates IAMFullAccessService-linked roles required by CloudFront and SSO Enter a Role name (e.g.
GitHubActionsRole).Review the Trust policy and Permissions policies at the bottom of the page. If you need to customise the trust policy, refer to Customise the trust policy below before proceeding.
Click Create role.
After creation: If you need to make changes, go to the role page and open the Permissions tab to modify attached policies, or the Trust relationships tab to edit the trust policy.
Customise the trust policy (optional)
Replace
<ACCOUNT_ID>,<ORG>, and<REPO>with your actual values. Your Account ID is the 12-digit number shown in the top-right corner of the AWS Console next to your account name.
Allow a specific branch only:
json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::<ACCOUNT_ID>: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:<ORG>/<REPO>:ref:refs/heads/main"
}
}
}
]
}Allow all branches in a repo:
json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::<ACCOUNT_ID>:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
},
"StringLike": {
"token.actions.githubusercontent.com:sub": "repo:<ORG>/<REPO>:*"
}
}
}
]
}Allow multiple repositories:
json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::<ACCOUNT_ID>:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
},
"StringLike": {
"token.actions.githubusercontent.com:sub": ["repo:<ORG>/<REPO>:*", "repo:<ORG>/<REPO>:*"]
}
}
}
]
}Step 3 of 3 — Enter the Values in ZenInstaller
On the role summary page, find the ARN — it looks like:
arn:aws:iam::<ACCOUNT_ID>:role/<ROLE_NAME>Return to the ZenInstaller page and open the Environment step. In the AWS section, enter:
| Field | Where to find it |
|---|---|
AWS_ROLE_ARN | The full ARN from the role summary page (e.g. arn:aws:iam::123456789012:role/GitHubActionsRole) |
ZenInstaller will save this as a GitHub Actions variable in your repository automatically.