forked from aws-samples/amazon-sagemaker-secure-mlops
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata-science-environment-quickstart.yaml
More file actions
216 lines (191 loc) · 7.84 KB
/
Copy pathdata-science-environment-quickstart.yaml
File metadata and controls
216 lines (191 loc) · 7.84 KB
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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
AWSTemplateFormatVersion: '2010-09-09'
Description: |
This template provisions an end-to-end secure Data Science environment with MLOps project template.
It deploys:
- a VPC with two private and public subnets
- two NAT gateways: one in each availability zone
- route tables
- security groups
- VPC endpoints
- IAM roles and KMS keys
- Amazon S3 buckets for SageMaker data and models
- SageMaker Studio domain and default user profile
- AWS Service Catalog portfolios and products
**WARNING** This template creates AWS resources. You will be billed for the AWS
resources used if you create a stack from this template.
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Data Science environment
Parameters:
- EnvName
- EnvType
- Label:
default: Deployment Options
Parameters:
- CreateSharedServices
- Label:
default: S3 Bucket Name with MLOps Seed Code
Parameters:
- SeedCodeS3BucketName
- Label:
default: Network Configuration
Parameters:
- VPCCIDR
- PrivateSubnet1ACIDR
- PrivateSubnet2ACIDR
- PrivateSubnet3ACIDR
- PublicSubnet1CIDR
- PublicSubnet2CIDR
- PublicSubnet3CIDR
ParameterLabels:
EnvName:
default: Environment name
EnvType:
default: Environment type
CreateSharedServices:
default: Create Shared Services (PyPI mirror)
SeedCodeS3BucketName:
default: Existing S3 bucket name where MLOps seed code will be stored
VPCCIDR:
default: VPC CIDR block
PrivateSubnet1ACIDR:
default: Private subnet 1A CIDR
PrivateSubnet2ACIDR:
default: Private subnet 2A CIDR
PublicSubnet1CIDR:
default: Public subnet 1 CIDR
PublicSubnet2CIDR:
default: Public subnet 2 CIDR
Outputs:
AssumeDSAdministratorRole:
Description: URL for assuming the role of a cross-environment data science admin
Value: !GetAtt DataScienceCore.Outputs.AssumeDSAdministratorRole
AssumeTeamAdminRole:
Description: URL for assuming the role of a environment admin
Value: !GetAtt DataScienceEnvironment.Outputs.AssumeTeamAdminRole
AssumeDataScientistRole:
Description: URL for assuming the role of a environment user
Value: !GetAtt DataScienceEnvironment.Outputs.AssumeDataScientistRole
SageMakerDomainId:
Description: SageMaker Domain Id
Value: !GetAtt DataScienceEnvironment.Outputs.SageMakerDomainId
Parameters:
EnvName:
Type: String
AllowedPattern: '[a-z0-9\-]*'
Description: Please specify your data science environment name. Used as a prefix for environment resource names.
EnvType:
Description: System Environment (e.g. dev, test, prod). Used as a prefix for environment resource names.
Type: String
Default: dev
CreateSharedServices:
Type: String
Default: 'NO'
AllowedValues:
- 'YES'
- 'NO'
Description: Set to YES if you do want to provision the shared services VPC network and PyPi mirror repository
SeedCodeS3BucketName:
Description: S3 bucket name to store MLOps seed code (the S3 bucket must exist)
Type: String
VPCCIDR:
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(1[6-9]|2[0-8]))$
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.0.0/16
Description: CIDR block for the new VPC
Type: String
PrivateSubnet1ACIDR:
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(1[6-9]|2[0-8]))$
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.0.0/19
Description: CIDR block for private subnet 1A located in Availability Zone 1
Type: String
PrivateSubnet2ACIDR:
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(1[6-9]|2[0-8]))$
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.32.0/19
Description: CIDR block for private subnet 2A located in Availability Zone 2
Type: String
PrivateSubnet3ACIDR:
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(1[6-9]|2[0-8]))$
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.64.0/19
Description: CIDR block for private subnet 3A located in Availability Zone 3
Type: String
PublicSubnet1CIDR:
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(1[6-9]|2[0-8]))$
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.128.0/20
Description: CIDR block for the public DMZ subnet 1 located in Availability Zone 1
Type: String
PublicSubnet2CIDR:
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(1[6-9]|2[0-8]))$
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.144.0/20
Description: CIDR block for the public DMZ subnet 2 located in Availability Zone 2
Type: String
PublicSubnet3CIDR:
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(1[6-9]|2[0-8]))$
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
Default: 10.0.160.0/20
Description: CIDR block for the public DMZ subnet 3 located in Availability Zone 3
Type: String
Rules:
CIDR:
Assertions:
- Assert: !And
- !Not [ !Equals [ !Ref VPCCIDR, '' ] ]
- !Not [ !Equals [ !Ref PrivateSubnet1ACIDR, '' ] ]
- !Not [ !Equals [ !Ref PrivateSubnet2ACIDR, '' ] ]
- !Not [ !Equals [ !Ref PrivateSubnet3ACIDR, '' ] ]
- !Not [ !Equals [ !Ref PublicSubnet1CIDR, '' ] ]
- !Not [ !Equals [ !Ref PublicSubnet2CIDR, '' ] ]
- !Not [ !Equals [ !Ref PublicSubnet3CIDR, '' ] ]
AssertDescription: You must provide all CIDR blocks for VPC, three private and three public subnets
Conditions:
SharedServicesCondition: !Equals [ !Ref CreateSharedServices, 'YES' ]
Resources:
# Core and shared services
DataScienceCore:
Type: AWS::CloudFormation::Stack
Properties:
Parameters:
StackSetName: 'ds-quickstart'
CreateSharedServices: !Ref CreateSharedServices
TemplateURL: core-main.yaml
Tags:
- Key: EnvironmentName
Value: !Ref EnvName
- Key: EnvironmentType
Value: !Ref EnvType
# Data Science environment
DataScienceEnvironment:
Type: AWS::CloudFormation::Stack
DependsOn: 'DataScienceCore'
Properties:
Parameters:
EnvName: !Ref EnvName
EnvType: !Ref EnvType
StartKernelGatewayApps: 'YES'
UseSharedServicesPyPiMirror: !If [ SharedServicesCondition, 'YES', 'NO' ]
AvailabilityZones: !Join
- ','
- - !Sub '${AWS::Region}a'
- !Sub '${AWS::Region}b'
NumberOfAZs: '2'
VPCCIDR: !Ref VPCCIDR
PrivateSubnet1ACIDR: !Ref PrivateSubnet1ACIDR
PrivateSubnet2ACIDR: !Ref PrivateSubnet2ACIDR
PublicSubnet1CIDR: !Ref PublicSubnet1CIDR
PublicSubnet2CIDR: !Ref PublicSubnet2CIDR
SeedCodeS3BucketName: !Ref SeedCodeS3BucketName
TemplateURL: env-main.yaml
Tags:
- Key: EnvironmentName
Value: !Ref EnvName
- Key: EnvironmentType
Value: !Ref EnvType