-
Notifications
You must be signed in to change notification settings - Fork 241
/
studio.yml
211 lines (205 loc) · 7.72 KB
/
studio.yml
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
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
ProjectPrefix:
Type: String
Description: |
Unique prefix to make resource privileges scoped-limited.
Changing the default must be done with care
Default: mlops
SageMakerStudioRoleName:
Type: String
Description: Name of the role used by SageMaker Studio
MinLength: 1
AllowedPattern: ^[a-zA-Z](-*[a-zA-Z0-9])*
PortfolioName:
Type: String
Default: SageMaker Safe Deployment Pipeline Templates
TemplateName:
Type: String
Default: SageMaker Safe Deployment Pipeline
PipelineBucket:
Type: String
Default: S3 bucket to store the pipeline cloudformation template
Resources:
SageMakerStudioOrganizationProjectsPortfolio:
Type: AWS::ServiceCatalog::Portfolio
Properties:
Description: "Creates a new portfolio with a template for SageMakerProjects"
DisplayName: !Ref PortfolioName
ProviderName: "SageMaker Safe Deployment Pipeline Templates"
SageMakerSafeDeploymentProduct:
Type: AWS::ServiceCatalog::CloudFormationProduct
Properties:
Description: Deploys the template for creating a new SageMaker setup
Name: !Ref TemplateName
Owner: MLOps
ProvisioningArtifactParameters:
- Description: "SageMaker Safe Deployment Pipeline Project Templates"
DisableTemplateValidation: false
Info:
LoadTemplateFromURL: !Sub "https://${PipelineBucket}.s3.${AWS::Region}.amazonaws.com/pipeline.yml"
Tags:
- Key: sagemaker:studio-visibility
Value: "true"
LaunchRoleConstraint:
Type: AWS::ServiceCatalog::LaunchRoleConstraint
Properties:
Description: "This is a launch constraint restriction for the SageMaker Launch Role"
PortfolioId: !Ref SageMakerStudioOrganizationProjectsPortfolio
ProductId: !Ref SageMakerSafeDeploymentProduct
RoleArn: !Sub "arn:aws:iam::${AWS::AccountId}:role/service-role/AmazonSageMakerServiceCatalogProductsLaunchRole"
DependsOn:
- ProductAssociation
- AdditionalPrivilegesForStudio
PrincipalAssociation:
Type: AWS::ServiceCatalog::PortfolioPrincipalAssociation
Properties:
PortfolioId: !Ref SageMakerStudioOrganizationProjectsPortfolio
PrincipalType: IAM
PrincipalARN: !Sub arn:aws:iam::${AWS::AccountId}:role/${SageMakerStudioRoleName}
ProductAssociation:
Type: AWS::ServiceCatalog::PortfolioProductAssociation
Properties:
PortfolioId: !Ref SageMakerStudioOrganizationProjectsPortfolio
ProductId: !Ref SageMakerSafeDeploymentProduct
AdditionalPrivilegesForStudio:
Type: AWS::IAM::Policy
Properties:
PolicyName: SageMakerSafeDeploymentAdditional
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- "cloudtrail:*"
Resource:
- "*"
- Effect: Allow
Action:
- "cloudformation:DescribeStacks"
- "cloudformation:DescribeStackEvents"
- "cloudformation:DeleteStack"
Resource:
- !Sub "arn:aws:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/${ProjectPrefix}-*"
- Effect: Allow
Action:
- "codecommit:CreateRepository"
- "codecommit:GetRepository"
- "codecommit:GetBranch"
- "codecommit:DeleteRepository"
- "codecommit:TagResource"
- "codecommit:CreateCommit"
Resource:
- !Sub "arn:aws:codecommit:${AWS::Region}:${AWS::AccountId}:amazon-sagemaker-safe-deployment-pipeline*"
- Effect: Allow
Action:
- "codebuild:CreateProject"
- "codebuild:DeleteProject"
Resource:
- !Sub "arn:aws:codebuild:${AWS::Region}:${AWS::AccountId}:project/${ProjectPrefix}-*"
- Effect: Allow
Action:
- "codepipeline:CreatePipeline"
- "codepipeline:DeletePipeline"
- "codepipeline:GetPipeline"
- "codepipeline:GetPipelineState"
- "codepipeline:TagResource"
- "codepipeline:StartPipelineExecution"
Resource:
- !Sub "arn:aws:codepipeline:${AWS::Region}:${AWS::AccountId}:${ProjectPrefix}-*"
- Effect: Allow
Action:
- "codepipeline:PutApprovalResult"
Resource:
- !Sub "arn:aws:codepipeline:${AWS::Region}:${AWS::AccountId}:${ProjectPrefix}-*/DeployDev/ApproveDeploy"
- Effect: Allow
Action:
- "kms:*"
Resource:
- "*"
- Effect: Allow
Action:
- "iam:GetRole"
- "iam:PassRole"
- "iam:CreateRole"
- "iam:DeleteRole"
- "iam:GetRolePolicy"
- "iam:PutRolePolicy"
- "iam:AttachRolePolicy"
- "iam:DetachRolePolicy"
- "iam:DeleteRolePolicy"
- "iam:ListRoleTags"
- "iam:TagRole"
Resource:
- !Sub "arn:aws:iam::${AWS::AccountId}:role/${ProjectPrefix}-*"
- Effect: Allow
Action:
- "sns:GetTopicAttributes"
- "sns:SetTopicAttributes"
- "sns:CreateTopic"
- "sns:DeleteTopic"
- "sns:TagResource"
- "sns:UntagResource"
- "sns:Subscribe"
- "sns:Unsubscribe"
Resource:
!Sub "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:${ProjectPrefix}-*"
- Effect: Allow
Action:
- "s3:*"
Resource:
- !Sub "arn:aws:s3:::${ProjectPrefix}-*"
- !Sub "arn:aws:s3:::${PipelineBucket}*"
- Effect: Allow
Action:
- "events:PutRule"
- "events:DescribeRule"
- "events:PutTargets"
- "events:RemoveTargets"
- "events:DeleteRule"
Resource:
- !Sub "arn:aws:events:${AWS::Region}:${AWS::AccountId}:rule/${ProjectPrefix}-*"
- !Sub "arn:aws:events:${AWS::Region}:${AWS::AccountId}:rule/SC-${AWS::AccountId}*"
- Effect: Allow
Action:
- "servicecatalog:GetProvisionedProductOutputs"
Resource:
- !Sub "arn:aws:servicecatalog:${AWS::Region}:${AWS::AccountId}:*"
- Effect: Allow
Action:
- "states:DescribeStateMachine"
- "states:ListExecutions"
- "states:GetExecutionHistory"
- "states:CreateStateMachine"
- "states:StartExecution"
- "states:DescribeExecution"
- "states:DeleteStateMachine"
Resource:
- !Sub "arn:aws:states:${AWS::Region}:${AWS::AccountId}:*:${ProjectPrefix}-*"
- Effect: Allow
Action:
- "cloudwatch:PutDashboard"
- "cloudwatch:GetDashboard"
- "cloudwatch:DeleteAlarms"
- "cloudwatch:DeleteDashboards"
Resource:
- !Sub "arn:aws:cloudwatch::${AWS::AccountId}:dashboard/${ProjectPrefix}-*"
- Effect: Allow
Action:
- "cloudwatch:PutMetricData"
- "cloudwatch:GetMetricStatistics"
Resource:
"*"
Condition:
StringEquals:
cloudwatch:namespace: "aws/sagemaker/Endpoints/data-metrics"
- Effect: Allow
Action:
- "lambda:CreateFunction"
- "lambda:InvokeFunction"
- "lambda:PublishLayerVersion"
Resource:
- !Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:*:${ProjectPrefix}-*"
Roles:
- !Ref SageMakerStudioRoleName
- AmazonSageMakerServiceCatalogProductsLaunchRole