skip to Main Content

I am creating a Lambda function to start one SageMaker notebook instance as following:

import boto3
import logging
def lambda_handler(event, context):
    client = boto3.client('sagemaker')
    client.start_notebook_instance(NotebookInstanceName='experiment')
    return 0

I want to pass some information from event (e.g., S3 bucket name and the file name in the bucket) to the lifecycle configuration (LCC) of the SageMaker notebook instance. From the original post, I know I can not pass through client.start_notebook_instance(NotebookInstanceName='experiment'). My follow-up question is how can I pass event information to LCC? I have tried several ways, such as making use of the CloudWatch logs, but none of them works. Can anyone give me a hand? I want to stick with SageMaker notebook instance. Thank you.

2

Answers


  1. Chosen as BEST ANSWER

    I have figured out the solution. We can add one tag (https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker/client/add_tags.html) to the SageMaker notebook instance (the tag contains the event information), and then pass the tag to the notebook through lifecycle configuration.


  2. Why are you starting a notebook instance from lambda? If you want schedule jobs you should look at using SageMaker Training or Processing Jobs.

    If you want to pass data to the Lifecycle config you could write data to s3 and have code in the lifecycle config read the data from S3.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search