Deploying a Machine Learning Model with Amazon SageMaker

Deploying a Machine Learning Model with Amazon SageMaker
Deploying a Machine Learning Model with Amazon SageMaker

CLOUD LABS



Deploying a Machine Learning Model with Amazon SageMaker

In this Cloud Lab, you’ll learn how to deploy a machine learning model with Amazon SageMaker, provide access to it with a Lambda function, and trigger the Lambda function with API Gateway.

9 Tasks

beginner

1hr 30m

Certificate of Completion

Desktop OnlyDevice is not compatible.
No Setup Required
Amazon Web Services

Learning Objectives

Working knowledge of using Amazon SageMaker
Working knowledge of building and deploying a machine learning model
The ability to create and invoke a Lambda function
The ability to trigger a Lambda function with API Gateway

Technologies
Lambda logoLambda
API Gateway logoAPI Gateway
SageMaker
Cloud Lab Overview

Amazon SageMaker is an AWS-managed service that provides machine learning services. It provides an integrated Jupyter Notebook. Data scientists can easily access data, analyze and extract its features, train a machine learning model, evaluate it, and deploy it on a hosted environment. It provides native support for making our own machine learning algorithms and some commonly used algorithms that perform well on huge datasets.

In this Cloud Lab, you’ll make a notebook instance in Amazon SageMaker, deploy a machine learning model on the notebook instance, and host the model on an endpoint. Moreover, you’ll use a Lambda function to access the endpoint. At the end of the Cloud Lab, you’ll use an API gateway to trigger the Lambda function with a payload and get predictions in response.

The following is the high-level architecture diagram of the infrastructure you’ll create in this Cloud Lab:

Discover the architecture of Amazon SageMaker for deploying and managing machine learning models
Discover the architecture of Amazon SageMaker for deploying and managing machine learning models

Why deploying an ML model is often harder than training it

Training a model is only part of the job. The real challenge shows up when you need to make predictions reliably in a real application. You need infrastructure, an inference endpoint, an interface your app can call, and a way to test and evolve the system without breaking everything.

That’s why Amazon SageMaker is a popular choice for deployment: it gives you managed building blocks for hosting models and exposing them to applications, without forcing you to hand-roll everything from scratch.

What you’re building in this Cloud Lab

This Cloud Lab focuses on a clean, practical deployment pipeline:

  • Build inside a managed notebook environment: You’ll create a notebook instance in Amazon SageMaker and use it as the place where your model deployment starts. This mirrors how many teams prototype and validate models before they formalize a production workflow.

  • Host the model behind an endpoint: Instead of running inference locally, you’ll host the model on a SageMaker endpoint. This is the key step that turns your model into a service that can handle prediction requests.

  • Add a Lambda layer for simple inference access: Once you have an endpoint, you’ll create a Lambda function that invokes it. This is a common architectural move because Lambda gives you a lightweight “backend wrapper” where you can:

    • Validate inputs

    • Normalize request payloads

    • Control what you log

    • Return consistent responses to callers

  • Trigger inference through API Gateway: Finally, you’ll connect API Gateway to your Lambda function so you can send a request (with a payload) and get predictions back over HTTP. This gives you an end-to-end workflow that looks and feels like a real ML-powered API.

Where this pattern shows up in real projects

The architecture you practice here is a foundation for:

  • Product features that call ML inference in real time (recommendations, scoring, categorization).

  • Internal services that expose predictions to multiple teams.

  • Prototypes that need a shareable endpoint for testing and demos.

  • Early-stage MLOps setups before you add monitoring, CI/CD, or automated retraining.

Once you’re comfortable with the basics, the next natural steps are adding authentication, monitoring, deployment automation, and tighter cost controls. But having a working “model served behind an API” baseline is the prerequisite for all of that.

What “done” looks like

By the end of the Cloud Lab, you should be able to explain and repeat the full flow:

  • A model is hosted on a SageMaker endpoint.

  • Lambda invokes the endpoint for inference.

  • API Gateway triggers Lambda with a request payload.

  • The system returns a prediction response that you can integrate into an app.

That’s the core deployment life cycle many teams use as a starting point. It’s simple, testable, and easy to extend.

Cloud Lab Tasks
1.Introduction
Getting Started
2.Working with Amazon SageMaker
Create the Notebook Instance
Set Up the Notebook
3.Set Up the Lambda Function And the API Gateway
Create an Execution Role
Create a Lambda Function
Create an API Gateway
Deploy and Test the Function
4.Conclusion
Clean Up
Wrap Up
Labs Rules Apply
Stay within resource usage requirements.
Do not engage in cryptocurrency mining.
Do not engage in or encourage activity that is illegal.

Relevant Courses

Use the following content to review prerequisites or explore specific concepts in detail.

Hear what others have to say
Join 1.4 million developers working at companies like