AWS::SageMaker::NotebookInstanceLifecycleConfig
The AWS::SageMaker::NotebookInstanceLifecycleConfig resource creates
shell scripts that run when you create and/or start a notebook instance. For information
about notebook instance lifecycle configurations, see Customize a Notebook
Instance in the Amazon SageMaker Developer
Guide.
Syntax
To declare this entity in your Amazon CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::SageMaker::NotebookInstanceLifecycleConfig", "Properties" : { "NotebookInstanceLifecycleConfigName" :String, "OnCreate" :[ NotebookInstanceLifecycleHook, ... ], "OnStart" :[ NotebookInstanceLifecycleHook, ... ]} }
YAML
Type: AWS::SageMaker::NotebookInstanceLifecycleConfig Properties: NotebookInstanceLifecycleConfigName:StringOnCreate:- NotebookInstanceLifecycleHookOnStart:- NotebookInstanceLifecycleHook
Properties
NotebookInstanceLifecycleConfigName-
The name of the lifecycle configuration.
Required: No
Type: String
Maximum:
63Pattern:
^[a-zA-Z0-9](-*[a-zA-Z0-9])*Update requires: Replacement
OnCreate-
A shell script that runs only once, when you create a notebook instance. The shell script must be a base64-encoded string.
Required: No
Type: List of NotebookInstanceLifecycleHook
Maximum:
1Update requires: No interruption
OnStart-
A shell script that runs every time you start a notebook instance, including when you create the notebook instance. The shell script must be a base64-encoded string.
Required: No
Type: List of NotebookInstanceLifecycleHook
Maximum:
1Update requires: No interruption
Return values
Ref
When you pass the logical ID of this resource to the intrinsic Reffunction, Refreturns the Amazon Resource Name (ARN) of the endpoint
configuration, such as
arn:aws:sagemaker:us-west-2:012345678901:notebook-instance-lifecycle-config/mylifecycleconfig
For more information about using the Reffunction, see Ref.
Fn::GetAtt
The Fn::GetAttintrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.
For more information about using the Fn::GetAttintrinsic function, see Fn::GetAtt.
Fn::GetAtt returns a value for a specified attribute of this type. The
following are the available attributes and sample return values.
Examples
SageMaker NotebookInstanceLifecycleConfig Example
The following example creates a notebook instance with an associated lifecycle configuration.
JSON
{ "Description": "Basic NotebookInstance test", "Resources": { "BasicNotebookInstance": { "Type": "AWS::SageMaker::NotebookInstance", "Properties": { "InstanceType": "ml.t2.medium", "RoleArn": { "Fn::GetAtt" : [ "ExecutionRole", "Arn" ] }, "LifecycleConfigName": { "Fn::GetAtt" : [ "BasicNotebookInstanceLifecycleConfig", "NotebookInstanceLifecycleConfigName" ] } }, "BasicNotebookInstanceLifecycleConfig": { "Type": "AWS::SageMaker::NotebookInstanceLifecycleConfig", "Properties": { "OnStart": [ { "Content": { "Fn::Base64": "echo 'hello'" } } ] } }, "ExecutionRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "sagemaker.amazonaws.com" ] }, "Action": [ "sts:AssumeRole" ] } ] }, "Path": "/", "Policies": [ { "PolicyName": "root", "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "*", "Resource": "*" } ] } } ] } } }, "Outputs": { "BasicNotebookInstanceId": { "Value": { "Ref" : "BasicNotebookInstance" } }, "BasicNotebookInstanceLifecycleConfigId": { "Value": { "Ref" : "BasicNotebookInstanceLifecycleConfig" } } } } }
YAML
Description: "Basic NotebookInstance test" Resources: BasicNotebookInstance: Type: "AWS::SageMaker::NotebookInstance" Properties: InstanceType: "ml.t2.medium" RoleArn: !GetAtt ExecutionRole.Arn LifecycleConfigName: !GetAtt BasicNotebookInstanceLifecycleConfig.NotebookInstanceLifecycleConfigName BasicNotebookInstanceLifecycleConfig: Type: "AWS::SageMaker::NotebookInstanceLifecycleConfig" Properties: OnStart: - Content: Fn::Base64: "echo 'hello'" ExecutionRole: Type: "AWS::IAM::Role" Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Principal: Service: - "sagemaker.amazonaws.com" Action: - "sts:AssumeRole" Path: "/" Policies: - PolicyName: "root" PolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Action: "*" Resource: "*" Outputs: BasicNotebookInstanceId: Value: !Ref BasicNotebookInstance BasicNotebookInstanceLifecycleConfigId: Value: !Ref BasicNotebookInstanceLifecycleConfig