--- AWSTemplateFormatVersion: '2010-09-09' Description: AmazonLookoutForMetricsWorkshopRI2021 IAM Policies, and SageMaker Notebook to work with Amazon Lookout For Metrics. Parameters: NotebookName: Type: String Default: AmazonLookoutForMetricsWorkshopBook Description: Enter the name of the SageMaker notebook instance. Default is AmazonLookoutForMetricsWorkshopBook. VolumeSize: Type: Number Default: 5 MinValue: 5 MaxValue: 16384 ConstraintDescription: Must be an integer between 5 (GB) and 16384 (16 TB). Description: Enter the size of the EBS volume in GB. 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/AmazonLookoutMetricsFullAccess" - "arn:aws:iam::aws:policy/AWSGlueConsoleFullAccess" Policies: - PolicyName: quicksightFullAccess PolicyDocument: Version: "2012-10-17" Statement: - Effect: Allow Action: quicksight:* Resource: "*" # SageMaker notebook NotebookInstance: Type: "AWS::SageMaker::NotebookInstance" Properties: InstanceType: "ml.t2.medium" NotebookInstanceName: !Ref NotebookName RoleArn: !GetAtt SageMakerIamRole.Arn VolumeSizeInGB: !Ref VolumeSize LifecycleConfigName: !GetAtt AmazonL4MLifecycleConfig.NotebookInstanceLifecycleConfigName AmazonL4MLifecycleConfig: 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-lookout-for-metrics-samples cd /home/ec2-user/SageMaker/amazon-lookout-for-metrics-samples/workshops/RI2021/ml_ops/ nohup sh deploy.sh "${SAMArtifactsBucket}" & EOF