how do I automate the creation of a sagemaker endpoint?

I was thinking that I could create a lambda function to create the endpoint, then after the prediction is done, in the same function, clean the data and delete the endpoint, but this doesn’t seem to be possible since the maximum execution time of a lambda function is 15 minutes and the creation of the endpoint takes more than 10 minutes, it may work sometimes but it may not, so I’m looking for a different way, any suggestions?


Related discussions:

I would love some guidance on integration of sagemaker training and predictions into an automated production ci/cd system.

  1. can you use a batch transform, instead of a real-time endpoint?
  2. you could use lambda to launch the endpoint, then cloudwatch event rules to monitor the invocation of the endpoint, calling the lambda again to ask it to shutdown the endpoint
  3. or use a new serverless endpoint, which will be cheaper to run

In (1) I was told by the data scientist that it’s easier for him to control the pre and post processing using an endpoint, and also that the creation of the instance in batch transform takes as long as creating the endpoint so it wouldn’t make much difference

can you further explain how would (2) work? is there a way to pause the lambda function so as to not consume any more resources? when you launch the endpoint as well, doesn’t it have to wait for it to finish before ending the function? a 10 min lambda function is very expensive

regarding (3) what do you mean exactly by a new serverless endpoint?

I was thinking maybe I can create a ci/cd with SAM and put an API to launch the endpoint from there and then call the lambda function with that endpoint, i don’t know if what I’m saying it’s possible since i’ve never used it but does it seem viable?

is create endpoint blocking? I don’t believe it is. you should be able to call boto3 or whatever to request starting the endpoint, then immediately exit…

re 3: https://docs.aws.amazon.com/sagemaker/latest/dg/serverless-endpoints.html

Oh yeah, its true
But to invoke the lambda point i still need to finish creating the endpoint, id have to create another lambda function?

you could call the same lambda function, but with different arguments, to do different things…

Of course! I’m dumb, thanks!

false

Use a step function or SageMaker Pipelines to automate the creation and have post/pre processing

Use event bridge to monitor endpoint state changes and write a rule for what to do when the endpoint is in service https://docs.aws.amazon.com/sagemaker/latest/dg/automating-sagemaker-with-eventbridge.html#eventbridge-endpoint