1
+ Parameters :
2
+ GitHubOrg :
3
+ Type : String
4
+ Default : " aws"
5
+ Description : The GitHub organization to use for the repository.
6
+ GitHubRepositoryName :
7
+ Description : The name of the GitHub repository to create the role template in and to use for the CodeBuild.
8
+ Type : String
9
+ Default : " aws-sdk-java-v2"
10
+ OIDCProviderArn :
11
+ Description : Arn for the GitHub OIDC Provider.
12
+ Default : " "
13
+ Type : String
14
+ OidcRoleRoleName :
15
+ Description : Name of the role to use for the OIDC provider.
16
+ Default : " aws-sdk-for-java-v2-ci-role"
17
+ Type : String
18
+
19
+
20
+ Conditions :
21
+ CreateOIDCProvider : !Equals
22
+ - !Ref OIDCProviderArn
23
+ - " "
24
+
25
+ Resources :
26
+ OidcRole :
27
+ Type : AWS::IAM::Role
28
+ Properties :
29
+ RoleName : !Ref OidcRoleRoleName
30
+ AssumeRolePolicyDocument :
31
+ Statement :
32
+ - Effect : Allow
33
+ Action : sts:AssumeRoleWithWebIdentity
34
+ Principal :
35
+ Federated : !If
36
+ - CreateOIDCProvider
37
+ - !Ref GithubOidc
38
+ - !Ref OIDCProviderArn
39
+ Condition :
40
+ StringLike :
41
+ token.actions.githubusercontent.com:sub : !Sub repo:${GitHubOrg}/${GitHubRepositoryName}:*
42
+ Policies :
43
+ - PolicyName : !Sub "${AWS::StackName}-OIDC-Policy"
44
+ PolicyDocument :
45
+ Version : " 2012-10-17"
46
+ Statement :
47
+ - Effect : Allow
48
+ Action :
49
+ - codebuild:StartBuild
50
+ - codebuild:BatchGetBuilds
51
+ Resource :
52
+ - !Sub arn:aws:codebuild:${ AWS::Region }:${ AWS::AccountId }:project/aws-sdk-java-v2
53
+ - !Sub arn:aws:codebuild:${ AWS::Region }:${ AWS::AccountId }:project/aws-sdk-java-v2-JDK11
54
+ - !Sub arn:aws:codebuild:${ AWS::Region }:${ AWS::AccountId }:project/aws-sdk-java-v2-JDK17
55
+ - !Sub arn:aws:codebuild:${ AWS::Region }:${ AWS::AccountId }:project/aws-sdk-java-v2-JDK8-windows
56
+ - !Sub arn:aws:codebuild:${ AWS::Region }:${ AWS::AccountId }:project/aws-sdk-java-v2-native-image-test
57
+ - Effect : Allow
58
+ Action :
59
+ - logs:GetLogEvents
60
+ Resource :
61
+ - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log- group:/aws/codebuild/aws-sdk-java-v2:*
62
+ - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/aws-sdk-java-v2-JDK11:*
63
+ - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/aws-sdk-java-v2-JDK17:*
64
+ - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/aws-sdk-java-v2-JDK8-windows:*
65
+ - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/aws-sdk-java-v2-native-image-test:*
66
+
67
+ GithubOidc :
68
+ Type : AWS::IAM::OIDCProvider
69
+ Condition : CreateOIDCProvider
70
+ Properties :
71
+ Url : https://token.actions.githubusercontent.com
72
+ ClientIdList :
73
+ - sts.amazonaws.com
74
+ ThumbprintList :
75
+ - 6938fd4d98bab03faadb97b34396831e3780aea1
76
+
77
+ Outputs :
78
+ OidcRole :
79
+ Value : !GetAtt OidcRole.Arn
0 commit comments