paws-r/paws

How to make a SageMaker endpoint publicly available?

Opened this issue · 2 comments

Hello,

First of all, thank you so much for your packages, they really help me a lot!
This is not an issue, but a question I have.

I managed to deploy my machine learning model fully programatically using vetiver::vetiver_sm_build(), vetiver::vetiver_sm_model() and vetiver::vetiver_sm_endpoint() to Amazon SageMaker. I can also make predictions using the created endpoint with predict(new_endpoint, new_data). However, this only works if my AWS credentials are available in the project. My goal is to expose the model as a public API, i.e. anyone who knows the link can call it without needing my AWS credentials.

After doing a bit of research, I found the following post, which tells me that I need to use Amazon API Gateway to make my SageMaker endpont publicly available. These are quite a few manual tasks and I would like to know if you have any idea how I could automate these steps in R? My goal is to automate the entire deployment process: Starting with an fitted machine learning model and ending with a publicly available API to make predictions.

Any help/hints/suggestions are greatly appreciated!

Hi @stefanlinner interesting problem :) For a full answer I will have to play around with it first. However, off the top of my head this should be plausible with the current aws service coverage paws has to offer.

These services should give you the functionality you need to build an api gateway that can hit your sagemaker endpoint :) I will try and create an example in the next couple of days :D

Note: I would recommend having an IAM executable role for your AWS API Gateway already to use and not be built one the fly :) (AWS IAM permissions can be a pain at times).

Another option is the look at challice (Chalice is a framework for writing serverless apps in python. It allows you to quickly create and deploy applications that use AWS Lambda). In short it would add a lambda in between your AWS Api Gateway and Sagemaker Endpoint. But it "should be fairly" (famous last words ;)) quick to implement.

Hi,

Thanks for your quick reply!

That's already good news that you think it's possible! :D I'll definitely take a look at those references, thanks! A small example would definitely be incredibly helpful, thanks!

Yes, setting up an IAM role beforehand is not a problem. Because I can reuse it and don't have to set it up every time I want to deploy an API :)

I also stumbled across this post where they talk about AWS Lambda + API Gateway. One advantage of this serverless structure is lower cost, right? If I want to use AWS Lambda, would I need to use the challice framework possibly through reticulate? In other words, there is no pure R solution for this at the moment?