Last active
February 16, 2022 18:23
-
-
Save brysontyrrell/38037dc31ab70cad0b9061d6691d909e to your computer and use it in GitHub Desktop.
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 | |
# See https://github.com/aws-actions/configure-aws-credentials#sample-iam-role-cloudformation-template | |
Parameters: | |
GitHubOrg: | |
Type: String | |
RepositoryName: | |
Type: String | |
BranchName: | |
Type: String | |
Default: "*" | |
GitHubOIDCProviderArn: | |
Type: String | |
Conditions: | |
AllowAllBranches: !Equals | |
- !Ref BranchName | |
- "*" | |
Resources: | |
RepositoryRole: | |
Type: AWS::IAM::Role | |
Properties: | |
AssumeRolePolicyDocument: | |
Statement: | |
- Effect: Allow | |
Action: sts:AssumeRoleWithWebIdentity | |
Principal: | |
Federated: !ImportValue GitHubOIDCProviderArn | |
Condition: | |
ForAllValues:StringLike: | |
token.actions.githubusercontent.com:aud: sts.amazonaws.com | |
token.actions.githubusercontent.com:sub: !If | |
- AllowAllBranches | |
- !Sub repo:${GitHubOrg}/${RepositoryName}:* | |
- !Sub repo:${GitHubOrg}/${RepositoryName}:ref:refs/heads/${BranchName} | |
Policies: | |
- PolicyName: install-from-repo | |
PolicyDocument: | |
Version: 2012-10-17 | |
Statement: | |
- Action: | |
- codeartifact:GetAuthorizationToken | |
- codeartifact:ReadFromRepository | |
- sts:GetServiceBearerToken | |
Effect: Allow | |
Resource: "*" | |
Outputs: | |
RepositoryRoleArn: | |
Value: !GetAtt RepositoryRole.Arn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment