forked from aws-samples/amazon-personalize-immersion-day
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPersonalizeID.yaml
99 lines (90 loc) · 3.1 KB
/
PersonalizeID.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
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Creates an S3 Bucket, IAM Policies, and SageMaker Notebook needed for the Amazon Personalize Immersion Day.
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: "SageMaker notebook instance"
Parameters:
- NotebookName
- VolumeSize
- Label:
default: "Industry"
Parameters:
- domain
ParameterLabels:
NotebookName:
default: "Instance name"
VolumeSize:
default: "Volume size"
domain:
default: "Industry domain"
Parameters:
NotebookName:
Type: String
Default: AmazonPersonalizeImmersionDay
Description: Enter the name of the SageMaker notebook instance. Default is AmazonPersonalizeImmersionDay.
VolumeSize:
Type: Number
Default: 64
MinValue: 5
MaxValue: 16384
ConstraintDescription: Must be an integer between 5 (GB) and 16384 (16 TB).
Description: Enter the size of the SageMaker notebook instance EBS volume in GB.
domain:
Type: String
Default: Media
Description: Select the industry domain (Retail, Media, or CPG) to use for the Amazon Personalize Immersion Day.
AllowedValues:
- 'Retail'
- 'Media'
- 'CPG'
Resources:
SAMArtifactsBucket:
Type: AWS::S3::Bucket
# SageMaker Execution Role
SageMakerIamRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: Allow
Principal:
Service: sagemaker.amazonaws.com
Action: sts:AssumeRole
Path: "/"
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/IAMFullAccess"
- "arn:aws:iam::aws:policy/AWSCloudFormationFullAccess"
- "arn:aws:iam::aws:policy/AmazonS3FullAccess"
- "arn:aws:iam::aws:policy/AmazonSageMakerFullAccess"
- "arn:aws:iam::aws:policy/AWSStepFunctionsFullAccess"
- "arn:aws:iam::aws:policy/AWSLambda_FullAccess"
- "arn:aws:iam::aws:policy/AmazonSNSFullAccess"
- "arn:aws:iam::aws:policy/service-role/AmazonPersonalizeFullAccess"
# SageMaker notebook
NotebookInstance:
Type: "AWS::SageMaker::NotebookInstance"
Properties:
InstanceType: "ml.t3.medium"
NotebookInstanceName: !Ref NotebookName
RoleArn: !GetAtt SageMakerIamRole.Arn
VolumeSizeInGB: !Ref VolumeSize
LifecycleConfigName: !GetAtt AmazonPersonalizeMLOpsLifecycleConfig.NotebookInstanceLifecycleConfigName
AmazonPersonalizeMLOpsLifecycleConfig:
Type: "AWS::SageMaker::NotebookInstanceLifecycleConfig"
Properties:
OnStart:
- Content:
Fn::Base64:
!Sub |
#!/bin/bash
sudo -u ec2-user -i <<'EOF'
cd /home/ec2-user/SageMaker/
git clone https://github.com/aws-samples/amazon-personalize-immersion-day.git
cd /home/ec2-user/SageMaker/amazon-personalize-immersion-day/automation/ml_ops/
nohup sh deploy.sh "${SAMArtifactsBucket}" "${domain}" &
EOF