Created
September 13, 2022 12:34
-
-
Save jonesy1234/3e34f9f7d2904a3c84233ebe98564db8 to your computer and use it in GitHub Desktop.
GitHub Enterprise AWS OIDC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
AWSTemplateFormatVersion: 2010-09-09 | |
Description: GitHub Actions AWS Authentication with OIDC for GitHub Enterprise | |
Parameters: | |
GithubOrg: # can also be a regular user | |
Type: String | |
Default: mygithuborg | |
FullRepoName: | |
Type: String | |
Default: mygithuborg/sjramblings | |
Resources: | |
Role: | |
Type: AWS::IAM::Role | |
Properties: | |
RoleName: ExampleGithubRole | |
ManagedPolicyArns: [arn:aws:iam::aws:policy/ReadOnlyAccess] | |
AssumeRolePolicyDocument: | |
Statement: | |
- Effect: Allow | |
Action: sts:AssumeRoleWithWebIdentity | |
Principal: | |
Federated: !Ref GithubOidc | |
Condition: | |
StringLike: | |
mygithub.com/_services/token:aud: !Sub https://mygithub.com/${GithubOrg} | |
mygithub.com/_services/token:sub: !Sub repo:${FullRepoName}:* | |
GithubOidc: | |
Type: AWS::IAM::OIDCProvider | |
Properties: | |
Url: https://mygithub.com/_services/token | |
ThumbprintList: [6938fd4d98bab03faadb97b34396831e3780aea1] | |
ClientIdList: | |
- !Sub https://mygithub.com/${GithubOrg} | |
Outputs: | |
Role: | |
Value: !GetAtt Role.Arn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment