Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

AWS::SageMaker::NotebookInstanceLifecycleConfig

The AWS::SageMaker::NotebookInstanceLifecycleConfig resource specifies shell scripts that run when you create and/or start a notebook instance. For more information, see Customize a Notebook Instance in the Amazon SageMaker Developer Guide.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::SageMaker::NotebookInstanceLifecycleConfig", "Properties" : { "OnStart" : [ NotebookInstanceLifecycleHook, ... ], "NotebookInstanceLifecycleConfigName" : String, "OnCreate" : [ NotebookInstanceLifecycleHook, ... ] } }

YAML

Type: "AWS::SageMaker::NotebookInstanceLifecycleConfig" Properties: OnStart: - NotebookInstanceLifecycleHook NotebookInstanceLifecycleConfigName: String OnCreate: - NotebookInstanceLifecycleHook

Properties

OnStart

A shell script that runs once when you create a notebook instance, and then each time you start the notebook instance.

Required: No

Type: List of Amazon SageMaker NotebookInstanceLifecycleConfig NotebookInstanceLifecycleHook

Update requires: No interruption

NotebookInstanceLifecycleConfigName

The name of the lifecycle configuration.

Required: No

Type: String

Update requires: Replacement

OnCreate

A shell script that runs only once, when you create a notebook instance.

Required: No

Type: List of Amazon SageMaker NotebookInstanceLifecycleConfig NotebookInstanceLifecycleHook

Update requires: No interruption

Return Values

Ref

When you pass the logical ID of an AWS::SageMaker::NotebookInstanceLifecycleConfig resource to the intrinsic Ref function, the function returns the Amazon Resource Name (ARN) of the lifecycle configuration, such as arn:aws:sagemaker:us-west-2:012345678901:notebook-instance-lifecycle-config/mylifecycleconfig.

For more information about using the Ref function, see Ref.

Fn::GetAtt

Fn::GetAtt returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

NotebookInstanceLifecycleConfigName

The name of the lifecycle configuration, such as MyLifecycleConfig.

For more information about using Fn::GetAtt, see Fn::GetAtt.

Examples

Notebook Instance Lifecycle Config 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