forked from aws-samples/amazon-sagemaker-secure-mlops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore-iam-shared-roles.yaml
360 lines (339 loc) · 13 KB
/
core-iam-shared-roles.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
AWSTemplateFormatVersion: 2010-09-09
Description: Create shared IAM Roles for SageMaker Data Science Environment (both personas and execution roles)
Parameters:
DSAdministratorRoleName:
Description: The name of the DataScienceAdministrator role
Type: String
Default: 'DataScienceAdministrator'
SageMakerDetectiveControlExecutionRoleName:
Description: The name of the SageMakerDetectiveControlExecutionRole
Type: String
Default: 'DSSageMakerDetectiveControlRole'
SCLaunchRoleName:
Description: The name of the Service Catalog Launch role
Type: String
Default: 'DSServiceCatalogLaunchRole'
Outputs:
AssumeDSAdministratorRole:
Description: URL for assuming the role of a cross-environment data science admin
Value: !If
- DSAdministratorRoleCondition
- !Sub 'https://signin.aws.amazon.com/switchrole?account=${AWS::AccountId}&roleName=${DataScienceAdministratorRole}&displayName=${DataScienceAdministratorRole}'
- ''
DSAdministratorRoleArn:
Description: The ARN of the DataScienceAdministrator role
Value: !If
- DSAdministratorRoleCondition
- !GetAtt DataScienceAdministratorRole.Arn
- ''
SageMakerDetectiveControlExecutionRoleArn:
Description: The ARN of the SageMakerDetectiveControlExecutionRole
Value: !If
- SageMakerDetectiveControlExecutionRoleCondition
- !GetAtt SageMakerDetectiveControlExecutionRole.Arn
- ''
SCLaunchRoleArn:
Description: The ARN of the Service Catalog Launch role
Value: !If
- SCLaunchRoleCondition
- !GetAtt SCLaunchRole.Arn
- ''
Conditions:
DSAdministratorRoleCondition: !Not [ !Equals [ !Ref DSAdministratorRoleName, '' ] ]
SageMakerDetectiveControlExecutionRoleCondition: !Not [ !Equals [ !Ref SageMakerDetectiveControlExecutionRoleName, '' ] ]
SCLaunchRoleCondition: !Not [ !Equals [ !Ref SCLaunchRoleName, '' ] ]
Resources:
DataScienceAdministratorRole:
Condition: DSAdministratorRoleCondition
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
AWS:
- !Sub 'arn:aws:iam::${AWS::AccountId}:root'
Service:
- 'cloudformation.amazonaws.com'
- 'codepipeline.amazonaws.com'
Action:
- 'sts:AssumeRole'
RoleName: !Ref DSAdministratorRoleName
Policies:
- PolicyName: DataScienceAdministratorRoleInlinePolicy
PolicyDocument:
Version: 2012-10-17
Statement:
-
Action:
- lambda:CreateFunction
- lambda:DeleteFunction
- lambda:PutFunctionConcurrency
Resource:
- !Sub 'arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:*GetEnvironmentConfiguration*'
Effect: Allow
-
Action:
- iam:PassRole
Resource:
- !Sub 'arn:aws:iam::${AWS::AccountId}:role/service-role/AmazonSageMakerServiceCatalogProductsLaunchRole'
Effect: Allow
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/AWSServiceCatalogAdminFullAccess'
- 'arn:aws:iam::aws:policy/AWSKeyManagementServicePowerUser'
- 'arn:aws:iam::aws:policy/AmazonS3FullAccess'
- 'arn:aws:iam::aws:policy/AWSCloudFormationFullAccess'
- 'arn:aws:iam::aws:policy/ReadOnlyAccess'
- 'arn:aws:iam::aws:policy/AmazonSSMFullAccess'
- 'arn:aws:iam::aws:policy/AmazonSageMakerFullAccess'
SageMakerDetectiveControlExecutionRole:
Type: 'AWS::IAM::Role'
Condition: SageMakerDetectiveControlExecutionRoleCondition
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: 'sts:AssumeRole'
RoleName: !Ref SageMakerDetectiveControlExecutionRoleName
Policies:
- PolicyName: LambdaInlineForSageMaker
PolicyDocument:
Version: 2012-10-17
Statement:
- Sid: VisualEditor0
Effect: Allow
Action:
- 'sagemaker:DeleteTags'
- 'sagemaker:DeleteEndpointConfig'
- 'sagemaker:StopTrainingJob'
- 'sagemaker:DeleteModel'
- 'sagemaker:DeleteEndpoint'
- 'sagemaker:StopTransformJob'
- 'sagemaker:AddTags'
Resource:
- !Sub 'arn:aws:sagemaker:*:${AWS::AccountId}:*'
-
Action:
- 'sagemaker:List*'
Resource:
- '*'
Effect: Allow
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
SCLaunchRole:
Type: 'AWS::IAM::Role'
Condition: SCLaunchRoleCondition
Properties:
Description: Service Catalog launch role to deploy products from SC portfolio
RoleName: !Ref SCLaunchRoleName
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- 'servicecatalog.amazonaws.com'
- 'cloudformation.amazonaws.com'
- 'codepipeline.amazonaws.com'
Action:
- 'sts:AssumeRole'
Path: /
Policies:
- PolicyName: !Sub '${SCLaunchRoleName}-SCLaunchInlinePolicy'
PolicyDocument:
Version: 2012-10-17
Statement:
- Sid: LambdaPermission
Effect: Allow
Action:
- 'lambda:AddPermission'
- 'lambda:CreateFunction'
- 'lambda:DeleteFunction'
- 'lambda:GetFunction'
- 'lambda:GetFunctionConfiguration'
- 'lambda:InvokeFunction'
- 'lambda:RemovePermission'
- 'lambda:PutFunctionConcurrency'
Resource:
- !Sub 'arn:aws:lambda:*:${AWS::AccountId}:function:*'
- Effect: Allow
Action:
- 'lambda:ListFunctions'
Resource:
- '*'
- Sid: SageMakerPermission
Effect: Allow
Action:
- sagemaker:ListDomains
- sagemaker:CreateDomain
- sagemaker:DescribeDomain
- sagemaker:DeleteDomain
- sagemaker:UpdateDomain
- sagemaker:ListUserProfiles
- sagemaker:CreateUserProfile
- sagemaker:UpdateUserProfile
- sagemaker:DeleteUserProfile
- sagemaker:DescribeUserProfile
- sagemaker:ListApps
- sagemaker:CreateApp
- sagemaker:DescribeApp
- sagemaker:DeleteApp
- sagemaker:UpdateApp
- sagemaker:CreateNotebookInstanceLifecycleConfig
- sagemaker:DeleteNotebookInstanceLifecycleConfig
- sagemaker:DescribeNotebookInstanceLifecycleConfig
- sagemaker:Disassociate*
Resource:
- !Sub "arn:${AWS::Partition}:sagemaker:*:*:domain/*"
- !Sub "arn:${AWS::Partition}:sagemaker:*:*:user-profile/*"
- !Sub "arn:${AWS::Partition}:sagemaker:*:*:app/*"
- Sid: SageMakerProjectsPermission
Effect: Allow
Action:
- sagemaker:EnableSagemakerServicecatalogPortfolio
- sagemaker:DisableSagemakerServicecatalogPortfolio
Resource:
- '*'
- Sid: ServiceCatalogPermission
Effect: Allow
Action:
- 'servicecatalog:Accept*'
- 'servicecatalog:Associate*'
- 'servicecatalog:Create*'
- 'servicecatalog:Delete*'
- 'servicecatalog:Describe*'
- 'servicecatalog:Disable*'
- 'servicecatalog:Enable*'
- 'servicecatalog:Execute*'
- 'servicecatalog:Get*'
- 'servicecatalog:Provision*'
- 'servicecatalog:Scan*'
- 'servicecatalog:Terminate*'
- 'servicecatalog:Update*'
Resource:
- !Sub 'arn:aws:servicecatalog:*:${AWS::AccountId}:*'
- !Sub 'arn:aws:catalog:*:${AWS::AccountId}:*'
-
Effect: Allow
Action:
- 'servicecatalog:Disassociate*'
- 'servicecatalog:List*'
Resource:
- '*'
- Sid: IAMPermission
Effect: Allow
Action:
- 'iam:AttachRolePolicy'
- 'iam:CreateRole'
- 'iam:DeleteRole'
- 'iam:DeleteRolePolicy'
- 'iam:DetachRolePolicy'
- 'iam:GetRole'
- 'iam:GetRolePolicy'
- 'iam:ListPolicyVersions'
- 'iam:PutRolePolicy'
- 'iam:GetPolicy'
- 'iam:CreatePolicy'
- 'iam:DeletePolicy'
- 'iam:Tag*'
Resource:
- !Sub 'arn:aws:iam::${AWS::AccountId}:*'
- Sid: PassRolePermission
Action:
- iam:PassRole
Resource:
- !Sub 'arn:aws:iam::${AWS::AccountId}:role/*'
Effect: Allow
- Sid: KMSPermission
Effect: Allow
Action:
- 'kms:CreateAlias'
- 'kms:CreateGrant'
- 'kms:Decrypt'
- 'kms:DeleteAlias'
- 'kms:DeleteCustomKeyStore'
- 'kms:DeleteImportedKeyMaterial'
- 'kms:DescribeKey'
- 'kms:EnableKey'
- 'kms:ListAliases'
- 'kms:EnableKeyRotation'
- 'kms:GenerateDataKey'
- 'kms:PutKeyPolicy'
- 'kms:ScheduleKeyDeletion'
- 'kms:TagResource'
- 'kms:UpdateAlias'
- 'kms:UpdateCustomKeyStore'
- 'kms:UpdateKeyDescription'
Resource:
- !Sub 'arn:aws:kms:*:${AWS::AccountId}:*'
-
Effect: Allow
Action:
- 'kms:CreateKey'
Resource:
- '*'
-
Effect: Allow
Action:
- 'codecommit:CreateCommit'
- 'codecommit:CreateRepository'
- 'codecommit:DeleteRepository'
- 'codecommit:GetRepository'
- 'codecommit:TagResource'
Resource:
- !Sub 'arn:aws:codecommit:*:${AWS::AccountId}:*'
-
Effect: Allow
Action:
- 'codecommit:ListRepositories'
Resource:
- '*'
-
Effect: Allow
Action:
- 'config:DescribeConfigurationRecorderStatus'
- 'config:DescribeConfigurationRecorders'
Resource:
- '*'
-
Effect: Allow
Action:
- 'ec2:DescribeAvailabilityZones'
- 'ec2:CreateTags'
- 'ec2:DeleteTags'
- 'ec2:DescribeTags'
Resource:
- '*'
-
Effect: Allow
Action:
- 'resource-groups:CreateGroup'
- 'resource-groups:DeleteGroup'
- 'resource-groups:Tag'
- 'resource-groups:Untag'
Resource:
- '*'
-
Effect: Allow
Action:
- 'ssm:AddTagsToResource'
- 'ssm:DeleteParameter'
- 'ssm:DeleteParameters'
- 'ssm:GetParameter'
- 'ssm:GetParameters'
- 'ssm:PutParameter'
- 'ssm:RemoveTagsFromResource'
Resource:
- '*'
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/AmazonS3FullAccess'
- 'arn:aws:iam::aws:policy/AWSCloudFormationFullAccess'
- 'arn:aws:iam::aws:policy/CloudWatchLogsFullAccess'
- 'arn:aws:iam::aws:policy/AmazonVPCFullAccess'
- 'arn:aws:iam::aws:policy/AmazonElasticFileSystemFullAccess'