forked from laughingman7743/PyAthena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub_actions_oidc.yaml
130 lines (125 loc) · 3.75 KB
/
github_actions_oidc.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
Parameters:
GitHubOrg:
Type: String
RepositoryName:
Type: String
RoleName:
Type: String
Default: "github-actions-oidc-pyathena-test"
BucketName:
Type: String
WorkGroupName:
Type: String
Default: "pyathena-test"
OIDCProviderArn:
Type: String
Default: ""
Description: Arn for the GitHub OIDC Provider.
Conditions:
CreateOIDCProvider: !Equals
- !Ref OIDCProviderArn
- ""
Resources:
Role:
Type: AWS::IAM::Role
Properties:
RoleName: !Sub "${RoleName}"
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Action: sts:AssumeRoleWithWebIdentity
Principal:
Federated: !If
- CreateOIDCProvider
- !Ref GithubOidc
- !Ref OIDCProviderArn
Condition:
StringLike:
token.actions.githubusercontent.com:sub: !Sub "repo:${GitHubOrg}/${RepositoryName}:*"
Policies:
- PolicyName: athena-access
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: [
"athena:*"
]
Resource: [
"*"
]
- PolicyName: glue-access
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: [
"glue:CreateDatabase",
"glue:DeleteDatabase",
"glue:GetDatabase",
"glue:GetDatabases",
"glue:UpdateDatabase",
"glue:CreateTable",
"glue:DeleteTable",
"glue:BatchDeleteTable",
"glue:UpdateTable",
"glue:GetTable",
"glue:GetTables",
"glue:BatchCreatePartition",
"glue:CreatePartition",
"glue:DeletePartition",
"glue:BatchDeletePartition",
"glue:UpdatePartition",
"glue:GetPartition",
"glue:GetPartitions",
"glue:BatchGetPartition"
]
Resource: [
"*"
]
- PolicyName: s3-access
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: [
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket",
"s3:ListBucketMultipartUploads",
"s3:ListMultipartUploadParts",
"s3:AbortMultipartUpload",
"s3:CreateBucket",
"s3:PutObject",
"s3:PutBucketPublicAccessBlock",
"s3:DeleteObject"
]
Resource: [
!Sub "arn:aws:s3:::${BucketName}*"
]
WorkGroup:
Type: AWS::Athena::WorkGroup
Properties:
Name: !Sub "${WorkGroupName}"
State: ENABLED
WorkGroupConfiguration:
EnforceWorkGroupConfiguration: false
PublishCloudWatchMetricsEnabled: false
RequesterPaysEnabled: false
EngineVersion:
SelectedEngineVersion: "Athena engine version 3"
ResultConfiguration:
OutputLocation: !Sub "s3://${BucketName}/workgroup=pyathena-test/"
GithubOidc:
Type: AWS::IAM::OIDCProvider
Condition: CreateOIDCProvider
Properties:
Url: https://token.actions.githubusercontent.com
ClientIdList:
- sts.amazonaws.com
ThumbprintList:
- 6938fd4d98bab03faadb97b34396831e3780aea1
- 1c58a3a8518e8759bf075b76b750d4f2df264fcd
Outputs:
Role:
Value: !GetAtt Role.Arn