you can utilize sagemaker lifecycle configuration and specify path of your ipynb as below:
#!/bin/bash
set -x
apt update -y
sudo -u ec2-user -i <<'EOF'
# PARAMETERS
ENVIRONMENT=python3
NOTEBOOK_FILE=/home/ec2-user/SageMaker/yash-folder/Example_Notebook.ipynb
echo "Activating conda env"
source /home/ec2-user/anaconda3/bin/activate "$ENVIRONMENT"
echo "Starting notebook"
jupyter nbconvert "$NOTEBOOK_FILE" --ExecutePreprocessor.kernel_name=python --execute --to notebook
echo "Dectivating conda env"
source /home/ec2-user/anaconda3/bin/deactivate
and your lambda function will be able to trigger your sagemaker notebook instance using below code:
import boto3
import logging
def lambda_handler(event, context):
client = boto3.client('sagemaker')
client.start_notebook_instance(NotebookInstanceName='yashaswi-instance')
return 0
you can follow this post for your reference
https://medium.com/@yashaswi.kakumanu/struggling-to-schedule-sagemaker-notebooks-ebd7441cc80f