

# MLOps Automation With SageMaker Projects
<a name="sagemaker-projects"></a>

Create end-to-end ML solutions with CI/CD by using SageMaker Projects. 

Use SageMaker Projects to create a MLOps solution to orchestrate and manage:
+ Building custom images for processing, training, and inference
+ Data preparation and feature engineering
+ Training models
+ Evaluating models
+ Deploying models
+ Monitoring and updating models

**Topics**
+ [What is a SageMaker AI Project?](sagemaker-projects-whatis.md)
+ [Granting SageMaker Studio Permissions Required to Use Projects](sagemaker-projects-studio-updates.md)
+ [Create a MLOps Project using Amazon SageMaker Studio or Studio Classic](sagemaker-projects-create.md)
+ [MLOps Project Templates](sagemaker-projects-templates.md)
+ [View Project Resources](sagemaker-projects-resources.md)
+ [Update a MLOps Project in Amazon SageMaker Studio or Studio Classic](sagemaker-projects-update.md)
+ [Delete a MLOps Project using Amazon SageMaker Studio or Studio Classic](sagemaker-projects-delete.md)
+ [Walk Through a SageMaker AI MLOps Project Using Third-party Git Repos](sagemaker-projects-walkthrough-3rdgit.md)

# What is a SageMaker AI Project?
<a name="sagemaker-projects-whatis"></a>

SageMaker Projects help organizations set up and standardize developer environments for data scientists and CI/CD systems for MLOps engineers. Projects also help organizations set up dependency management, code repository management, build reproducibility, and artifact sharing.

You can provision SageMaker Projects using custom templates that are stored in Amazon S3 buckets, or by using templates from the AWS Service Catalog or SageMaker AI. For information about the AWS Service Catalog, see [What Is AWS Service Catalog](https://docs.aws.amazon.com/servicecatalog/latest/dg/what-is-service-catalog.html). With SageMaker Projects, MLOps engineers and organization admins can define their own templates or use SageMaker AI-provided templates. The SageMaker AI-provided templates bootstrap the ML workflow with source version control, automated ML pipelines, and a set of code to quickly start iterating over ML use cases.

## When Should You Use a SageMaker AI Project?
<a name="sagemaker-projects-when"></a>

**Important**  
Effective September 9, 2024, project templates that use the AWS CodeCommit repository are no longer supported. For new projects, select from the available project templates that use third-party Git repositories.

While notebooks are helpful for model building and experimentation, a team of data scientists and ML engineers sharing code needs a more scalable way to maintain code consistency and strict version control.

Every organization has its own set of standards and practices that provide security and governance for its AWS environment. SageMaker AI provides a set of first-party templates for organizations that want to quickly get started with ML workflows and CI/CD. The templates include projects that use AWS-native services for CI/CD, such as AWS CodeBuild, AWS CodePipeline, and AWS CodeCommit. The templates also offer the option to create projects that use third-party tools, such as Jenkins and GitHub. For a list of the project templates that SageMaker AI provides, see [Use SageMaker AI-Provided Project Templates](sagemaker-projects-templates-sm.md).

Organizations often need tight control over the MLOps resources that they provision and manage. Such responsibility assumes certain tasks, including configuring IAM roles and policies, enforcing resource tags, enforcing encryption, and decoupling resources across multiple accounts. SageMaker Projects can support all these tasks through custom template offerings where organizations use CloudFormation templates to define the resources needed for an ML workflow. Data Scientists can choose a template to bootstrap and pre-configure their ML workflow.

To get started, we recommend that you create and store custom templates inside an Amazon S3 bucket. Doing so lets you create a bucket in any supported Region for your organization. S3 supports version control, so you can maintain multiple versions of your templates and roll back if necessary. For information about how to create a project from template store in an Amazon S3 bucket, see [Using a template from an Amazon S3 bucket](sagemaker-projects-templates-custom.md#sagemaker-projects-templates-s3).

Alternatively, you can also create custom templates as Service Catalog products and you can provision them in the Studio or Studio Classic UI under **Organization Templates**. The Service Catalog is a service that helps organizations create and manage catalogs of products that are approved for use on AWS. For more information about creating custom templates, see [Build Custom SageMaker AI Project Templates – Best Practices](https://aws.amazon.com/blogs/machine-learning/build-custom-sagemaker-project-templates-best-practices/).

While you can use either option, we recommend that you use S3 buckets over the Service Catalog, so you can create a bucket in supported Regions where SageMaker AI is available without needing to manage the complexities of the Service Catalog.

SageMaker Projects can help you manage your Git repositories so that you can collaborate more efficiently across teams, ensure code consistency, and support CI/CD. SageMaker Projects can help you with the following tasks:
+ Organize all entities of the ML lifecycle under one project.
+ Establish a single-click approach to set up standard ML infrastructure for model training and deployment that incorporates best practices.
+ Create and share templates for ML infrastructure to serve multiple use cases.
+ Leverage SageMaker AI-provided pre-built templates to quickly start focusing on model building, or create custom templates with organization-specific resources and guidelines.
+ Integrate with tools of your choice by extending the project templates. For an example, see [Create a SageMaker AI Project to integrate with GitLab and GitLab Pipelines](https://aws.amazon.com/blogs/machine-learning/build-mlops-workflows-with-amazon-sagemaker-projects-gitlab-and-gitlab-pipelines/).
+ Organize all entities of the ML lifecycle under one project.

## What is in a SageMaker AI Project?
<a name="sagemaker-projects-within"></a>

Customers have the flexibility to set up their projects with the resources that best serve their use case. The example below showcases the MLOps setup for an ML workflow, including model training and deployment.

![\[\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/projects/projects-ml-workflow.png)


A typical project with a SageMaker AI-provided template might include the following:
+ One or more repositories with sample code to build and deploy ML solutions. These are working examples that you can modify for your needs. You own this code and can take advantage of the version-controlled repositories for your tasks.
+ A SageMaker AI pipeline that defines steps for data preparation, training, model evaluation, and model deployment, as shown in the following diagram.  
![\[\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/projects/pipeline-in-project-simple.png)
+ A CodePipeline or Jenkins pipeline that runs your SageMaker AI pipeline every time you check in a new version of the code. For information about CodePipeline, see [What is AWS CodePipeline.](https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome.html) For information about Jenkins, see [Jenkins User Documentation](https://www.jenkins.io/doc/).
+ A model group that contains model versions. Every time you approve the resulting model version from a SageMaker AI pipeline run, you can deploy it to a SageMaker AI endpoint.

Each SageMaker AI project has a unique name and ID that are applied as tags to all of the SageMaker AI and AWS resources created in the project. With the name and ID, you can view all of the entities associated with your project. These include:
+ Pipelines
+ Registered models
+ Deployed models (endpoints)
+ Datasets
+ Service Catalog products
+ CodePipeline and Jenkins pipelines
+ CodeCommit and third-party Git repositories

## Do I Need to Create a Project to Use SageMaker AI Pipelines?
<a name="sagemaker-projects-need"></a>

No. SageMaker pipelines are standalone entities just like training jobs, processing jobs, and other SageMaker AI jobs. You can create, update, and run pipelines directly within a notebook by using the SageMaker Python SDK without using a SageMaker AI project.

Projects provide an additional layer to help you organize your code and adopt operational best practices that you need for a production-quality system.

# Granting SageMaker Studio Permissions Required to Use Projects
<a name="sagemaker-projects-studio-updates"></a>

The Amazon SageMaker Studio (or Studio Classic) administrator and Studio (or Studio Classic) users that you add to your domain can view project templates provided by SageMaker AI and create projects with those templates. By default, the administrator can view the SageMaker AI templates in the Service Catalog console. The administrator can see what another user creates if the user has permission to use SageMaker Projects. The administrator can also view the CloudFormation template that the SageMaker AI project templates define in the Service Catalog console. For information about using the Service Catalog console, see [What Is Service Catalog](https://docs.aws.amazon.com/servicecatalog/latest/adminguide/introduction.html) in the *Service Catalog User Guide*.

Studio (and Studio Classic) users of the domain who are configured to use the same execution role as the domain by default have permission to create projects using SageMaker AI project templates.

**Important**  
Do not manually create your roles. Always create roles through **Studio Settings** using the steps described in the following procedure.

For users who use any role other than the domain's execution role to view and use SageMaker AI-provided project templates, you need to grant **Projects** permissions to the individual user profiles by turning on **Enable Amazon SageMaker AI project templates and Amazon SageMaker JumpStart** for Studio users when you add them to your domain. For more information about this step, see [Add user profiles](domain-user-profile-add.md). 

Since SageMaker Projects is backed by Service Catalog, you must add each role that requires access to SageMaker Projects to the **Amazon SageMaker AI Solutions and ML Ops products** Portfolio in the service catalog. You can do this in the **Groups, roles, and users** tab, as shown in the following image. If each user profile in Studio Classic has a different role, you should add each of those roles to the service catalog. You can also do this while creating a user profile in Studio Classic.

## Grant new domain roles access to projects
<a name="sagemaker-projects-grant-access"></a>

When you change your domain's execution role or add user profiles with different roles, you must grant these new roles access to the Service Catalog portfolio to use SageMaker Projects. Follow these steps to ensure all roles have the necessary permissions:

**To grant new domain roles access to projects**

1. Open the [Service Catalog console](https://console.aws.amazon.com/servicecatalog/).

1. In the left navigation menu, choose **Portfolios**.

1. Select the **Imported** section.

1. Select **Amazon SageMaker Solutions and ML Ops products**.

1. Choose the **Access** tab.

1. Choose **Grant access**.

1. In the **Grant access** dialog, select **Roles**.

1. Grant access for all roles that are used by the domain's user profiles, including:
   + The domain's execution role
   + Any custom execution roles assigned to individual user profiles

1. Choose **Grant access** to confirm.

**Important**  
You must complete this process whenever you change your domain's execution role or add user profiles with new execution roles. Without this access, users will not be able to create or use SageMaker Projects.

The following procedures show how to grant **Projects** permissions after you onboard to Studio or Studio Classic. For more information about onboarding to Studio or Studio Classic, see [Amazon SageMaker AI domain overview](gs-studio-onboard.md).

**To confirm that your SageMaker AI Domain has active project template permissions:**

1. Open the [SageMaker AI console](https://console.aws.amazon.com/sagemaker/).

1. On the left navigation pane, choose **Admin configurations**.

1. Under **Admin configurations**, choose **domains**. 

1. Select your domain.

1. Choose the **Domain Settings** tab.

1. Under **SageMaker Projects and JumpStart**, make sure the following options are turned on:
   + **Enable Amazon SageMaker AI project templates and Amazon SageMaker JumpStart for this account**
   + **Enable Amazon SageMaker AI project templates and Amazon SageMaker JumpStart for Studio users**

**To view a list of your roles:**

1. Open the [SageMaker AI console](https://console.aws.amazon.com/sagemaker/).

1. On the left navigation pane, choose **Admin configurations**.

1. Under **Admin configurations**, choose **domains**. 

1. Select your domain.

1. Choose the **Domain Settings** tab.

1. A list of your roles appears in the `Apps` card under the **Studio** tab.
**Important**  
As of July 25, we require additional roles to use project templates. Here is the complete list of roles you should see under `Projects`:  
`AmazonSageMakerServiceCatalogProductsLaunchRole` `AmazonSageMakerServiceCatalogProductsUseRole` `AmazonSageMakerServiceCatalogProductsApiGatewayRole` `AmazonSageMakerServiceCatalogProductsCloudformationRole` `AmazonSageMakerServiceCatalogProductsCodeBuildRole` `AmazonSageMakerServiceCatalogProductsCodePipelineRole` `AmazonSageMakerServiceCatalogProductsEventsRole` `AmazonSageMakerServiceCatalogProductsFirehoseRole` `AmazonSageMakerServiceCatalogProductsGlueRole` `AmazonSageMakerServiceCatalogProductsLambdaRole` `AmazonSageMakerServiceCatalogProductsExecutionRole`  
For descriptions of these roles, see [AWS Managed Policies for SageMaker Projects and JumpStart](security-iam-awsmanpol-sc.md).

# Create a MLOps Project using Amazon SageMaker Studio or Studio Classic
<a name="sagemaker-projects-create"></a>

**Important**  
Custom IAM policies that allow Amazon SageMaker Studio or Amazon SageMaker Studio Classic to create Amazon SageMaker resources must also grant permissions to add tags to those resources. The permission to add tags to resources is required because Studio and Studio Classic automatically tag any resources they create. If an IAM policy allows Studio and Studio Classic to create resources but does not allow tagging, "AccessDenied" errors can occur when trying to create resources. For more information, see [Provide permissions for tagging SageMaker AI resources](security_iam_id-based-policy-examples.md#grant-tagging-permissions).  
[AWS managed policies for Amazon SageMaker AI](security-iam-awsmanpol.md) that give permissions to create SageMaker resources already include permissions to add tags while creating those resources.

This procedure demonstrates how to create an MLOps project using Amazon SageMaker Studio Classic.

**Prerequisites**
+ An IAM account or IAM Identity Center to sign in to Studio or Studio Classic. For more information, see [Amazon SageMaker AI domain overview](gs-studio-onboard.md).
+ Permission to use SageMaker AI-provided project templates. For more information, see [Granting SageMaker Studio Permissions Required to Use Projects](sagemaker-projects-studio-updates.md).
+ Basic familiarity with the Studio Classic user interface. For nore information, see [Amazon SageMaker Studio Classic UI Overview](studio-ui.md).

------
#### [ Studio ]

1. Open the SageMaker Studio console by following the instructions in [Launch Amazon SageMaker Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated-launch.html).

1. In the left navigation pane, choose **Deployments**, and then choose **Projects**.

1. In the upper-right corner above the projects list, choose **Create project**.

1. In the **Templates** page, choose a template to use for your project. For more information about project templates, see [MLOps Project Templates](sagemaker-projects-templates.md).

1. Choose **Next**.

1. In the **Project details** page, enter the following information:
   + **Name**: A name for your project.
   + **Description**: An optional description for your project.
   + The values for the Service Catalog provisioning parameters related to your chosen template.

1. Choose **Create project** and wait for the project to appear in the **Projects** list.

1. (Optional) In the Studio sidebar, choose **Pipelines** to view the pipeline created from your project. For more information about Pipelines, see [Pipelines](pipelines.md).

------
#### [ Studio Classic ]

1. Sign in to Studio Classic. For more information, see [Amazon SageMaker AI domain overview](gs-studio-onboard.md).

1. In the Studio Classic sidebar, choose the **Home** icon ( ![\[Black square icon representing a placeholder or empty image.\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/studio/icons/house.png)).

1. Select **Deployments** from the menu, and then select **Projects**.

1. Choose **Create project**.

   The **Create project** tab opens displaying a list of available templates.

1. If not selected already, choose **SageMaker AI templates**. For more information about project templates, see [MLOps Project Templates](sagemaker-projects-templates.md).

1. Choose the template **Model building, training, and deployment**.

1. Choose **Select project template**.

   The **Create project** tab changes to display **Project details**.

1. Enter the following information:
   + For **Project details**, enter a name and description for your project.
   + Optionally, add tags, which are key-value pairs that you can use to track your projects.

1. Choose **Create project** and wait for the project to appear in the **Projects** list.

------

# MLOps Project Templates
<a name="sagemaker-projects-templates"></a>

An Amazon SageMaker AI project template automates the setup and implementation of MLOps for your projects. A SageMaker AI project template is an Service Catalog product that SageMaker AI makes available to Amazon SageMaker Studio (or Studio Classic) users. These Service Catalog products are visible in your Service Catalog console after you enable permissions when you onboard or update Amazon SageMaker Studio (or Studio Classic). For information about enabling permissions to use SageMaker AI project templates, see [Granting SageMaker Studio Permissions Required to Use Projects](sagemaker-projects-studio-updates.md). Use SageMaker AI project templates to create a project that is an end-to-end MLOps solution.

You can use a SageMaker Projects template to implement image-building CI/CD. With this template, you can automate the CI/CD of images that are built and pushed to Amazon ECR. Changes in the container files in your project’s source control repositories initiate the ML pipeline and deploy the latest version for your container. For more information, see the blog [Create Amazon SageMaker Projects with image building CI/CD pipelines](https://aws.amazon.com/blogs/machine-learning/create-amazon-sagemaker-projects-with-image-building-ci-cd-pipelines/).

If you are an administrator, you can create custom project templates from scratch or modify one of the project templates provided by SageMaker AI. Studio (or Studio Classic) users in your organization can use these custom project templates to create their projects.

**Topics**
+ [Use SageMaker AI-Provided Project Templates](sagemaker-projects-templates-sm.md)
+ [Create Custom Project Templates](sagemaker-projects-templates-custom.md)

# Use SageMaker AI-Provided Project Templates
<a name="sagemaker-projects-templates-sm"></a>

**Important**  
As of October 28, 2024, the AWS CodeCommit templates have been removed. For new projects, select from the available project templates that use third-party Git repositories.

Amazon SageMaker AI provides project templates that create the infrastructure you need to create an MLOps solution for continuous integration and continuous deployment (CI/CD) of ML models. Use these templates to process data, extract features, train and test models, register the models in the SageMaker Model Registry, and deploy the models for inference. You can customize the seed code and the configuration files to suit your requirements.

**Note**  
Additional roles are required to use project templates. For a complete list of required roles and instructions on how to create them, see [Granting SageMaker Studio Permissions Required to Use Projects](sagemaker-projects-studio-updates.md). If you do not have the new roles, you will get the error message **CodePipeline is not authorized to perform AssumeRole on role arn:aws:iam::xxx:role/service-role/AmazonSageMakerServiceCatalogProductsCodePipelineRole** when you try to create a new project and cannot proceed.

SageMaker AI project templates offer you the following choice of code repositories, workflow automation tools, and pipeline stages:
+ **Code repository**: Third-party Git repositories such as GitHub and Bitbucket
+ **CI/CD workflow automation**: AWS CodePipeline or Jenkins
+ **Pipeline stages**: Model building and training, model deployment, or both

The following discussion provides an overview of each template you can choose when you create your SageMaker AI project. You can also view the available templates in Studio (or Studio Classic) by following [Create the Project](https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-projects-walkthrough.html#sagemaker-proejcts-walkthrough-create) of the [Project walkthrough](https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-projects-walkthrough.html).

For step-by-step instructions on how to create a real project, you can follow one of the project walkthroughs:
+ If you want to use the template [MLOps templates for model building, training, and deployment with third-party Git using CodePipeline](#sagemaker-projects-templates-git-code-pipeline), see [Walk Through a SageMaker AI MLOps Project Using Third-party Git Repos](sagemaker-projects-walkthrough-3rdgit.md).
+ If you want to use the template [MLOps templates for model building, training, and deployment with third-party Git repositories using Jenkins](#sagemaker-projects-templates-git-jenkins), see [Create Amazon SageMaker Projects using third-party source control and Jenkins](https://aws.amazon.com/blogs/machine-learning/create-amazon-sagemaker-projects-using-third-party-source-control-and-jenkins/).

**Topics**

## MLOps templates for model building, training, and deployment with third-party Git using CodePipeline
<a name="sagemaker-projects-templates-git-code-pipeline"></a>
+ **Code repository**: Third-party Git.
**Note**  
Establish the AWS CodeStar connection from your AWS account to your GitHub user or organization. Add a tag with the key `sagemaker` and value `true` to this AWS CodeStar connection.
+ **CI/CD workflow automation**: AWS CodePipeline

### Model building and training
<a name="sagemaker-projects-templates-git-code-pipeline-building-training"></a>

This template provides the following resources:
+ Associations with one customer-specified Git repositories. Repository contains sample code that creates an Amazon SageMaker AI pipeline in Python code and shows how to create and update the SageMaker AI pipeline. This repository also has a sample Python notebook that you can open and run in Studio (or Studio Classic).
+ An AWS CodePipeline pipeline that has source and build steps. The source step points to the third-party Git repository. The build step gets the code from that repository, creates and updates the SageMaker AI pipeline, starts a pipeline execution, and waits for the pipeline execution to complete.
+ An AWS CodeBuild project to populate the Git repositories with the seed code information. This requires an AWS CodeStar connection from your AWS account to your account on the Git repository host.
+ An Amazon S3 bucket to store artifacts, including CodePipeline and CodeBuild artifacts, and any artifacts generated from the SageMaker AI pipeline runs.

### Model deployment
<a name="sagemaker-projects-templates-git-code-pipeline-deployment"></a>

This template provides the following resources:
+ Associations with one customer-specified Git repositories. Repository contains sample code that deploys models to endpoints in staging and production environments.
+ An AWS CodePipeline pipeline that has source, build, deploy-to-staging, and deploy-to-production steps. The source step points to the third-party Git repository and the build step gets the code from that repository and generates CloudFormation stacks to deploy. The deploy-to-staging and deploy-to-production steps deploy the CloudFormation stacks to their respective environments. There is a manual approval step between the staging and production build steps, so that a MLOps engineer must approve the model before it is deployed to production.
+ An AWS CodeBuild project to populate the Git repositories with the seed code information. This requires an AWS CodeStar connection from your AWS account to your account on the Git repository host.
+ An Amazon S3 bucket to store artifacts, including CodePipeline and CodeBuild artifacts, and any artifacts generated from the SageMaker AI pipeline runs.

### Model building, training, and deployment
<a name="sagemaker-projects-templates-git-code-pipeline-building-training-deployment"></a>

This template provides the following resources:
+ Associations with one or more customer-specified Git repositories.
+ An AWS CodePipeline pipeline that has source, build, deploy-to-staging, and deploy-to-production steps. The source step points to the third-party Git repository and the build step gets the code from that repository and generates CloudFormation stacks to deploy. The deploy-to-staging and deploy-to-production steps deploy the CloudFormation stacks to their respective environments. There is a manual approval step between the staging and production build steps, so that a MLOps engineer must approve the model before it is deployed to production.
+ An AWS CodeBuild project to populate the Git repositories with the seed code information. This requires an AWS CodeStar connection from your AWS account to your account on the Git repository host.
+ An Amazon S3 bucket to store artifacts, including CodePipeline and CodeBuild artifacts, and any artifacts generated from the SageMaker AI pipeline runs.

As previously mentioned, see [Project Walkthrough Using Third-party Git Repos](https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-projects-walkthrough-3rdgit.html) for a demonstration that uses this template to create a real project.

## MLOps template for model building, training, deployment, and Amazon SageMaker Model Monitor using CodePipeline
<a name="sagemaker-projects-template-model-monitor"></a>
+ **Code repository**: Third-party Git.
**Note**  
Establish the AWS CodeStar connection from your AWS account to your GitHub user or organization. Add a tag with the key `sagemaker` and value `true` to this AWS CodeStar connection.
+ **CI/CD workflow automation**: AWS CodePipeline

The following templates include an additional Amazon SageMaker Model Monitor template that provides the following types of monitoring:
+ [Data Quality](https://docs.aws.amazon.com/sagemaker/latest/dg/model-monitor-data-quality.html) – Monitor drift in data quality.
+ [Model Quality](https://docs.aws.amazon.com/sagemaker/latest/dg/model-monitor-model-quality.html) – Monitor drift in model quality metrics, such as accuracy.
+ [Bias Drift for Models in Production](https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-model-monitor-bias-drift.html) – Monitor bias in a model's predictions.

### Model building, training, deployment, and Amazon SageMaker Model Monitor
<a name="sagemaker-projects-template-model-monitor-training-deployment-model-monitor"></a>

This template is an extension of the MLOps template for model building, training, and deployment with Git repositories using CodePipeline. It includes both the model building, training, and deployment components of the template, and an additional Amazon SageMaker Model Monitor template that provides the following types of monitoring: 

### Monitor a deployed model
<a name="sagemaker-projects-template-model-monitor-deploy"></a>

You can use this template for an MLOps solution to deploy one or more of the Amazon SageMaker AI data quality, model quality, model bias, and model explainability monitors to monitor a deployed model on a SageMaker AI inference endpoint. This template provides the following resources: 
+ Associations with one or more customer-specified Git repositories. Repository contains sample Python code that gets the [baselines](https://docs.aws.amazon.com/sagemaker/latest/dg/model-monitor-create-baseline.html) used by the monitors from the Amazon SageMaker Model Registry, and updates the template’s parameters for the staging and production environments. It also contains a CloudFormation template to create the Amazon SageMaker Model Monitors.
+ An AWS CodePipeline pipeline that has source, build, and deploy steps. The source step points to the CodePipeline repository. The build step gets the code from that repository, gets the baseline from the Model Registry, and updates template parameters for the staging and production environments. The deploy steps deploy the configured monitors into the staging and production environments. The manual approval step, within the `DeployStaging` stage, requires you to verify that the production SageMaker AI endpoint is `InService` before approving and moving to the `DeployProd` stage.
+ An AWS CodeBuild project to populate the Git repositories with the seed code information. This requires an AWS CodeStar connection from your AWS account to your account on the Git repository host.
+ The template uses the same Amazon S3 bucket created by the MLOps template for model building, training, and deployment to store the monitors' outputs.
+ Two Amazon EventBridge events rules initiate the Amazon SageMaker Model Monitor AWS CodePipeline every time the staging SageMaker AI endpoint is updated.

## MLOps templates for model building, training, and deployment with third-party Git repositories using Jenkins
<a name="sagemaker-projects-templates-git-jenkins"></a>
+ **Code repository**: Third-party Git.
**Note**  
Establish the AWS CodeStar connection from your AWS account to your GitHub user or organization. Add a tag with the key `sagemaker` and value `true` to this AWS CodeStar connection.
+ **CI/CD workflow automation**: Jenkins

### Model building, training, and deployment
<a name="sagemaker-projects-templates-git-jenkins-building-training-deployment"></a>

This template provides the following resources:
+ Associations with one or more customer-specified Git repositories.
+ Seed code to generate Jenkins pipelines that have source, build, deploy-to-staging, and deploy-to-production steps. The source step points to the customer-specified Git repository. The build step gets the code from that repository and generates two CloudFormation stacks. The deploy steps deploy the CloudFormation stacks to their respective environments. There is an approval step between the staging step and the production step.
+ An AWS CodeBuild project to populate the Git repositories with the seed code information. This requires an AWS CodeStar connection from your AWS account to your account on the Git repository host.
+ An Amazon S3 bucket to store artifacts of the SageMaker AI project and SageMaker AI pipeline.

The template creates the association between your project and the source control repositories, but you need to perform additional manual steps to establish communication between your AWS account and Jenkins. For the detailed steps, see [Create Amazon SageMaker Projects using third-party source control and Jenkins](https://aws.amazon.com/blogs/machine-learning/create-amazon-sagemaker-projects-using-third-party-source-control-and-jenkins/).

The instructions help you build the architecture shown in the following diagram, with GitHub as the source control repository in this example. As shown, you are attaching your Git repository to the project to check in and manage code versions. Jenkins initiates the model build pipeline when it detects changes to the model build code in the Git repository. You are also connecting the project to Jenkins to orchestrate your model deployment steps, which start when you approve the model registered in the model registry, or when Jenkins detects changes to the model deployment code.



![\[\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/projects/projects-templates-gitjenkins.png)


In summary, the steps guide you through the following tasks:

1. Establish the connection between your AWS and GitHub accounts.

1. Create the Jenkins account and import needed plugins.

1. Create the Jenkins IAM user and permissions policy.

1. Set the AWS credentials for the Jenkins IAM user on your Jenkins server.

1. Create an API token for communication with your Jenkins server.

1. Use a CloudFormation template to set up an EventBridge rule to monitor the model registry for newly-approved models.

1. Create the SageMaker AI project, which seeds your GitHub repositories with model build and deploy code.

1. Create your Jenkins model build pipeline with the model build seed code.

1. Create your Jenkins model deploy pipeline with the model deploy seed code.

## MLOps template for image building, model building, and model deployment
<a name="sagemaker-projects-templates-image-building-model-building-deployment"></a>

This template is an extension of the [MLOps templates for model building, training, and deployment with third-party Git using CodePipeline](#sagemaker-projects-templates-git-code-pipeline). It includes both the model building, training, and deployment components of that template and the following options:
+ Include processing image–building pipeline
+ Include training image–building pipeline
+ Include inference image–building pipeline

For each of the components selected during project creation, the following are created by using the template:
+ An Amazon ECR repository
+ [A SageMaker Image](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateImage.html)
+ A CodeCommit repository containing a Dockerfile that you can customize
+ A CodePipeline that is initiated by changes to the CodePipeline repository
+ A CodeBuild project that builds a Docker image and registers it in the Amazon ECR repository
+ An EventBridge rule that initiates the CodePipeline on a schedule

When the CodePipeline is initiated, it builds a new Docker container and registers it with an Amazon ECR repository. When a new container is registered with the Amazon ECR repository, a new `ImageVersion` is added to the SageMaker image. This initiates the model building pipeline, which in turn initiates the deployment pipeline.

The newly created image is used in the model building, training, and deployment portions of the workflow where applicable.

## Update SageMaker Projects to Use Third-Party Git Repositories
<a name="sagemaker-projects-templates-update"></a>

The managed policy attached to the `AmazonSageMakerServiceCatalogProductsUseRole` role was updated on July 27, 2021 for use with the third-party Git templates. Users who onboard to Amazon SageMaker Studio (or Studio Classic) after this date and enable project templates use the new policy. Users who onboarded prior to this date must update the policy to use these templates. Use one of the following options to update the policy:
+ Delete role and toggle Studio (or Studio Classic) settings

  1. In the IAM console, delete `AmazonSageMakerServiceCatalogProductsUseRole`.

  1. In the Studio (or Studio Classic) control panel, choose **Edit Settings**.

  1. Toggle both settings and then choose **Submit**.
+ In the IAM console, add the following permissions to `AmazonSageMakerServiceCatalogProductsUseRole`:

  ```
  {
        "Effect": "Allow",
        "Action": [
            "codestar-connections:UseConnection"
        ],
        "Resource": "arn:aws:codestar-connections:*:*:connection/*",
        "Condition": {
            "StringEqualsIgnoreCase": {
                "aws:ResourceTag/sagemaker": "true"
            }
        }
    },
    {
        "Effect": "Allow",
        "Action": [
            "s3:PutObjectAcl"
        ],
        "Resource": [
            "arn:aws:s3:::sagemaker-*"
        ]
    }
  ```

# Create Custom Project Templates
<a name="sagemaker-projects-templates-custom"></a>

**Important**  
As of October 28, 2024, the AWS CodeCommit templates have been removed. For new projects, select from the available project templates that use third-party Git repositories. For more information, see [MLOps Project Templates](sagemaker-projects-templates.md).

If the SageMaker AI-provided templates do not meet your needs (for example, you want to have more complex orchestration in the CodePipeline with multiple stages or custom approval steps), create your own templates.

We recommend starting by using SageMaker AI-provided templates to understand how to organize your code and resources and build on top of it. To do this, after you enable administrator access to the SageMaker AI templates, log in to the [https://console.aws.amazon.com/servicecatalog/](https://console.aws.amazon.com/servicecatalog/), choose **Portfolios**, then choose **Imported**. For information about Service Catalog, see [Overview of Service Catalog](https://docs.aws.amazon.com/servicecatalog/latest/adminguide/what-is_concepts.html) in the *Service Catalog User Guide*.

Create your own project templates to customize your MLOps project. SageMaker AI project templates are Service Catalog–provisioned products to provision the resources for your MLOps project. 

To create a custom project template, complete the following steps.

1. Create a portfolio. For information, see [Step 3: Create an Service Catalog Portfolio](https://docs.aws.amazon.com/servicecatalog/latest/adminguide/getstarted-portfolio.html).

1. Create a product. A product is a CloudFormation template. You can create multiple versions of the product. For information, see [Step 4: Create an Service Catalog Product](https://docs.aws.amazon.com/servicecatalog/latest/adminguide/getstarted-product.html).

   For the product to work with SageMaker Projects, add the following parameters to your product template.

   ```
   SageMakerProjectName:
   Type: String
   Description: Name of the project
   
   SageMakerProjectId:
   Type: String
   Description: Service generated Id of the project.
   ```
**Important**  
We recommend that you wrap the CodeCommit repository into the SageMaker AI code repository for the project's repositories to be visible in VPC mode. The sample template and required addition are shown in the following code samples.  
Original (sample) template:  

   ```
   ModelBuildCodeCommitRepository:
       Type: AWS::CodeCommit::Repository
       Properties:
         # Max allowed length: 100 chars
         RepositoryName: !Sub sagemaker-${SageMakerProjectName}-${SageMakerProjectId}-modelbuild # max: 10+33+15+10=68
         RepositoryDescription: !Sub SageMaker Model building workflow infrastructure as code for the Project ${SageMakerProjectName}
         Code:
           S3:
             Bucket: SEEDCODE_BUCKETNAME
             Key: toolchain/model-building-workflow-v1.0.zip
           BranchName: main
   ```
Additional content to add in VPC mode:  

   ```
   SageMakerRepository:
       Type: AWS::SageMaker::CodeRepository
       Properties:
           GitConfig:
               RepositoryUrl: !GetAtt ModelBuildCodeCommitRepository.CloneUrlHttp
               Branch: main
   ```

1. Add a launch constraint. A launch constraint designates an IAM role that Service Catalog assumes when a user launches a product. For information, see [Step 6: Add a Launch Constraint to Assign an IAM Role](https://docs.aws.amazon.com/servicecatalog/latest/adminguide/getstarted-launchconstraint.html).

1. Provision the product on [https://console.aws.amazon.com/servicecatalog/](https://console.aws.amazon.com/servicecatalog/) to test the template. If you are satisfied with your template, continue to the next step to make the template available in Studio (or Studio Classic).

1. Grant access to the Service Catalog portfolio that you created in step 1 to your Studio (or Studio Classic) execution role. Use either the domain execution role or a user role that has Studio (or Studio Classic) access. For information about adding a role to the portfolio, see [Step 7: Grant End Users Access to the Portfolio](https://docs.aws.amazon.com/servicecatalog/latest/adminguide/getstarted-deploy.html).

1. To make your project template available in your **Organization templates** list in Studio (or Studio Classic), create a tag with the following key and value to the Service Catalog product you created in step 2.
   + **key**: `sagemaker:studio-visibility`
   + **value**: `true`

After you complete these steps, Studio (or Studio Classic) users in your organization can create a project with the template you created by following the steps in [Create a MLOps Project using Amazon SageMaker Studio or Studio Classic](sagemaker-projects-create.md) and choosing **Organization templates** when you choose a template.

## Using a template from an Amazon S3 bucket
<a name="sagemaker-projects-templates-s3"></a>

You can also create SageMaker projects using templates stored in Amazon S3.

**Note**  
While you can use the templates in the AWS Service Catalog, we recommend that you store templates in an S3 bucket and create projects using those templates.

### Admin setup
<a name="sagemaker-projects-templates-s3-setup"></a>

Before you can create projects using templates in an S3 bucket, perform the following steps.

1. [Create an S3 bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html), and upload your templates to the bucket.

1. [Set up a CORS policy on your S3 bucket to configure access permissions](https://docs.aws.amazon.com/AmazonS3/latest/userguide/enabling-cors-examples.html).

1. Add the following key-value tag to the template so they become visible to SageMaker AI.

   ```
   sagemaker:studio-visibility : true
   ```

1. [Create a domain](https://docs.aws.amazon.com/sagemaker/latest/dg/onboard-quick-start.html).

1. After SageMaker AI finishes creating your domain, add the following key-value tag to the domain:

   ```
   sagemaker:projectS3TemplatesLocation : s3://<amzn-s3-demo-bucket>
   ```

Then use the AWS console, Python, or the [CreateProject](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateProject.html) and [UpdateProject](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateProject.html) API operations to create or update a SageMaker project from templates inside the S3 bucket.

------
#### [ Studio ]

**Create a project**

1. Open the Amazon SageMaker AI console at [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/).

1. Open the SageMaker Studio console by following the instructions in [Launch Amazon SageMaker Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated-launch.html).

1. In the left navigation pane, choose **Deployments**, **Projects**, **Create project**.

1. Choose **Organization templates** and then **S3 Templates** to see the templates that are available to you. If you don't see a template that you're expecting, notify your administrator.

1. Choose the template that you want to use, and then choose **Next**.

1. Enter a name for your project, an optional description, and the other required fields. When you're done, choose **Create**.

**Update a project**

1. Open the Amazon SageMaker AI console at [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/).

1. Open the SageMaker Studio console by following the instructions in [Launch Amazon SageMaker Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated-launch.html).

1. Choose the project that you want to update. Choose **Actions**, then choose **Update Project**.

1. When updating a project, you can update the template parameters or the template URL. When you're done, choose **Next**.

1. Review the project updates in the summary table, and choose **Update**.

------
#### [ Python Boto3 ]

After you create the S3 bucket and uploaded your templates, you can use the following example to create a SageMaker project.

```
sagemaker_client = boto3.client('sagemaker', region_name='us-west-2')

response = sagemaker_client.create_project(
    ProjectName='my-custom-project',
    ProjectDescription='SageMaker project with custom CFN template stored in S3',
    TemplateProviders=[{
        'CfnTemplateProvider': {
            'TemplateName': 'CustomProjectTemplate',
            'TemplateURL': f'https://<bucket_name>.s3.us-west-2.amazonaws.com/custom-project-template.yml',
            'Parameters': [
                {'Key': 'ParameterKey', 'Value': 'ParameterValue'}
            ]
        }
    }]
)
print(f"Project ARN: {response['ProjectArn']}")
```

To update a SageMaker project, see the following example.

```
sagemaker_client = boto3.client('sagemaker', region_name='us-west-2')

response = sagemaker_client.update_project(
    ProjectName='my-custom-project',
    ProjectDescription='SageMaker project with custom CFN template stored in S3',
    TemplateProvidersToUpdate=[{
        'CfnTemplateProvider': {
            'TemplateName': 'CustomProjectTemplate',
            'TemplateURL': f'https://<bucket_name>.s3.us-west-2.amazonaws.com/custom-project-template.yml',
            'Parameters': [
                {'Key': 'ParameterKey', 'Value': 'ParameterValue'}
            ]
        }
    }]
)
print(f"Project ARN: {response['ProjectArn']}")
```

------

# View Project Resources
<a name="sagemaker-projects-resources"></a>

After you create a project, view the resources associated with the project in Amazon SageMaker Studio Classic.

------
#### [ Studio ]

1. Open the SageMaker Studio console by following the instructions in [Launch Amazon SageMaker Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated-launch.html).

1. In the left navigation pane, choose **Deployments**, and then choose **Projects**.

1. Select the name of the project for which you want to view details. A page with the project details appears.

On the project details page, you can view the following entities can open any of the following tabs corresponding to the entity associated with the project.
+ Repositories: Code repositories (repos) associated with this project. If you use a SageMaker AI-provided template when you create your project, it creates a AWS CodeCommit repo or a third-party Git repo. For more information about CodeCommit, see [What is AWS CodeCommit](https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html).
+ Pipelines: SageMaker AI ML pipelines that define steps to prepare data, train, and deploy models. For information about SageMaker AI ML pipelines, see [Pipelines actions](pipelines-build.md).
+ Experiments: One or more Amazon SageMaker Autopilot experiments associated with the project. For information about Autopilot, see [SageMaker Autopilot](autopilot-automate-model-development.md).
+ Model groups: Groups of model versions that were created by pipeline executions in the project. For information about model groups, see [Create a Model Group](model-registry-model-group.md).
+ Endpoints: SageMaker AI endpoints that host deployed models for real-time inference. When a model version is approved, it is deployed to an endpoint.
+ Tags: All the tags associated with the project. For more information about tags, see [Tagging AWS resources](https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html) in the *AWS General Reference*.
+ Metadata: Metadata associated with the project. This includes the template and version used, and the template launch path.

------
#### [ Studio Classic ]

1. Sign in to Studio Classic. For more information, see [Amazon SageMaker AI domain overview](gs-studio-onboard.md).

1. In the Studio Classic sidebar, choose the **Home** icon ( ![\[Black square icon representing a placeholder or empty image.\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/studio/icons/house.png)).

1. Select **Deployments** from the menu, and then select **Projects**.

1. Select the name of the project for which you want to view details.

   A tab with the project details appears.

On the project details tab, you can view the following entities associated with the project.
+ Repositories: Code repositories (repos) associated with this project. If you use a SageMaker AI-provided template when you create your project, it creates a AWS CodeCommit repo or a third-party Git repo. For more information about CodeCommit, see [What is AWS CodeCommit](https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html).
+ Pipelines: SageMaker AI ML pipelines that define steps to prepare data, train, and deploy models. For information about SageMaker AI ML pipelines, see [Pipelines actions](pipelines-build.md).
+ Experiments: One or more Amazon SageMaker Autopilot experiments associated with the project. For information about Autopilot, see [SageMaker Autopilot](autopilot-automate-model-development.md).
+ Model groups: Groups of model versions that were created by pipeline executions in the project. For information about model groups, see [Create a Model Group](model-registry-model-group.md).
+ Endpoints: SageMaker AI endpoints that host deployed models for real-time inference. When a model version is approved, it is deployed to an endpoint.
+ Settings: Settings for the project. This includes the name and description of the project, information about the project template and `SourceModelPackageGroupName`, and metadata about the project.

------

# Update a MLOps Project in Amazon SageMaker Studio or Studio Classic
<a name="sagemaker-projects-update"></a>

This procedure demonstrates how to update a MLOps project in Amazon SageMaker Studio or Studio Classic. Updating the project gives you the option to modify your end-to-end ML solution. You can update the **Description**, template version, and template parameters.

**Prerequisites**
+ An IAM account or IAM Identity Center to sign in to Studio or Studio Classic. For information, see [Amazon SageMaker AI domain overview](gs-studio-onboard.md).
+ Basic familiarity with the Studio or Studio Classic user interface. For information about the Studio UI, see [Amazon SageMaker Studio](studio-updated.md). For information about Studio Classic, see [Amazon SageMaker Studio Classic UI Overview](studio-ui.md).
+ Add the following custom inline policies to the specified roles:

  User-created role having `AmazonSageMakerFullAccess`

------
#### [ JSON ]

****  

  ```
  {
      "Version":"2012-10-17",		 	 	 
      "Statement": [
          {
              "Effect": "Allow",
              "Action": [
                  "servicecatalog:CreateProvisionedProductPlan",
                  "servicecatalog:DescribeProvisionedProductPlan",
                  "servicecatalog:DeleteProvisionedProductPlan"
              ],
              "Resource": "*"
          }
      ]
  }
  ```

------

  `AmazonSageMakerServiceCatalogProductsLaunchRole`

------
#### [ JSON ]

****  

  ```
  {
      "Version":"2012-10-17",		 	 	 
      "Statement": [
          {
              "Effect": "Allow",
              "Action": [
                  "cloudformation:CreateChangeSet",
                  "cloudformation:DeleteChangeSet",
                  "cloudformation:DescribeChangeSet"
              ],
              "Resource": "arn:aws:cloudformation:*:*:stack/SC-*"
          },
          {
              "Effect": "Allow",
              "Action": [
                  "codecommit:PutRepositoryTriggers"
              ],
              "Resource": "arn:aws:codecommit:*:*:sagemaker-*"
          }
      ]
  }
  ```

------

To update your project in Studio or Studio Classic, complete the following steps.

------
#### [ Studio ]

1. Open the SageMaker Studio console by following the instructions in [Launch Amazon SageMaker Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated-launch.html).

1. In the left navigation pane, choose **Deployments**, and then choose **Projects**.

1. Choose the radio button next to the project you want to update.

1. Choose the vertical ellipsis above the upper-right corner of the projects list, and choose **Update**.

1. Choose **Next**.

1. Review the project updates in the summary table, and choose **Update**. It may take a few minutes for the project to update.

------
#### [ Studio Classic ]

**To update a project in Studio Classic**

1. Sign in to Studio Classic. For more information, see [Amazon SageMaker AI domain overview](gs-studio-onboard.md).

1. In the Studio Classic sidebar, choose the **Home** icon ( ![\[Black square icon representing a placeholder or empty image.\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/studio/icons/house.png)).

1. Select **Deployments** from the menu, and then select **Projects**. A list of your projects appears.

1. Select the name of the project you want to update in the projects list.

1. Choose **Update** from the **Actions** menu in the upper-right corner of the project tab.

1. In the **Update project** dialog box, you can edit the **Description** and listed template parameters.

1. Choose **View difference**.

   A dialog box displays your original and updated project settings. Any change in your project settings can modify or delete resources in the current project. The dialog box displays these changes as well.

1. You may need to wait a few minutes for the **Update** button to become active. Choose **Update**.

1. The project update may take a few minutes to complete. Select **Settings** in the project tab and ensure the parameters have been updated correctly.

------

# Delete a MLOps Project using Amazon SageMaker Studio or Studio Classic
<a name="sagemaker-projects-delete"></a>

This procedure demonstrates how to delete a MLOps project using Amazon SageMaker Studio or Studio Classic.

**Prerequisites**

**Note**  
You can only delete projects in Studio or Studio Classic that you have created. This condition is part of the service catalog permission `servicecatalog:TerminateProvisionedProduct` in the `AmazonSageMakerFullAccess` policy. If needed, you can update this policy to remove this condition.
+ An IAM account or IAM Identity Center to sign in to Studio or Studio Classic. For information, see [Amazon SageMaker AI domain overview](gs-studio-onboard.md).
+ Basic familiarity with the Studio or Studio Classic user interface. For information about the Studio UI, see [Amazon SageMaker Studio](studio-updated.md). For information about Studio Classic, see [Amazon SageMaker Studio Classic UI Overview](studio-ui.md).

------
#### [ Studio ]

1. Open the SageMaker Studio console by following the instructions in [Launch Amazon SageMaker Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated-launch.html).

1. In the left navigation pane, choose **Deployments**, and then choose **Projects**.

1. Choose the radio button next to the project you want to delete.

1. Choose the vertical ellipsis above the upper-right corner of the projects list, and choose **Delete**.

1. Review the information in the **Delete project** dialog box, and choose **Yes, delete the project** if you still want to delete the project.

1. Choose **Delete**.

1. Your projects list appears. Confirm that your project no longer appears in the list.

------
#### [ Studio Classic ]

1. Sign in to Studio Classic. For more information, see [Amazon SageMaker AI domain overview](gs-studio-onboard.md).

1. In the Studio Classic sidebar, choose the **Home** icon ( ![\[Black square icon representing a placeholder or empty image.\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/studio/icons/house.png)).

1. Select **Deployments** from the menu, and then select **Projects**.

1. Select the target project from the dropdown list. If you don’t see your project, type the project name and apply the filter to find your project.

1. Once you've found your project, select the project name to view details.

1. Choose **Delete** from the **Actions** menu.

1. Confirm your choice by choosing **Delete** from the **Delete Project** window.

------

# Walk Through a SageMaker AI MLOps Project Using Third-party Git Repos
<a name="sagemaker-projects-walkthrough-3rdgit"></a>

**Important**  
As of November 30, 2023, the previous Amazon SageMaker Studio experience is now named Amazon SageMaker Studio Classic. The following section is specific to using the Studio Classic application. For information about using the updated Studio experience, see [Amazon SageMaker Studio](studio-updated.md).  
Studio Classic is still maintained for existing workloads but is no longer available for onboarding. You can only stop or delete existing Studio Classic applications and cannot create new ones. We recommend that you [migrate your workload to the new Studio experience](studio-updated-migrate.md).

This walkthrough uses the template [MLOps templates for model building, training, and deployment with third-party Git using CodePipeline](sagemaker-projects-templates-sm.md#sagemaker-projects-templates-git-code-pipeline) to demonstrate how to use MLOps projects to create a CI/CD system to build, train, and deploy models.

**Prerequisites**

To complete this walkthrough, you need:
+ An IAM or IAM Identity Center account to sign in to Studio Classic. For information, see [Amazon SageMaker AI domain overview](gs-studio-onboard.md).
+ Permission to use SageMaker AI-provided project templates. For information, see [Granting SageMaker Studio Permissions Required to Use Projects](sagemaker-projects-studio-updates.md).
+ Basic familiarity with the Studio Classic user interface. For information, see [Amazon SageMaker Studio Classic UI Overview](studio-ui.md).
+ Two empty GitHub repositories. You input these repositories into the project template, which will seed these repos with model build and deploy code.

**Topics**
+ [Step 1: Set up the GitHub connection](#sagemaker-proejcts-walkthrough-connect-3rdgit)
+ [Step 2: Create the Project](#sagemaker-proejcts-walkthrough-create-3rdgit)
+ [Step 3: Make a Change in the Code](#sagemaker-projects-walkthrough-change-3rdgit)
+ [Step 4: Approve the Model](#sagemaker-proejcts-walkthrough-approve-3rdgit)
+ [(Optional) Step 5: Deploy the Model Version to Production](#sagemaker-projects-walkthrough-prod-3rdgit)
+ [Step 6: Clean Up Resources](#sagemaker-projectcts-walkthrough-cleanup-3rdgit)

## Step 1: Set up the GitHub connection
<a name="sagemaker-proejcts-walkthrough-connect-3rdgit"></a>

In this step, you connect to your GitHub repositories using an [AWS CodeConnections connection](https://docs.aws.amazon.com/dtconsole/latest/userguide/welcome-connections.html). The SageMaker AI project uses this connection to access your source code repositories.

**To set up the GitHub connection:**

1. Log in to the CodePipeline console at [https://console.aws.amazon.com/codepipeline/](https://console.aws.amazon.com/codepipeline/)

1. Under **Settings** in the navigation pane, choose **Connections**.

1. Choose **Create connection**.

1. For **Select a provider**, select **GitHub**.

1. For **Connection name**, enter a name.

1. Choose **Connect to GitHub**.

1. If the AWS Connector GitHub app isn’t previously installed, choose **Install new app**.

   This displays a list of all the GitHub personal accounts and organizations to which you have access.

1. Choose the account where you want to establish connectivity for use with SageMaker Projects and GitHub repositories.

1. Choose **Configure**.

1. You can optionally select your specific repositories or choose **All repositories**.

1. Choose **Save**. When the app is installed, you’re redirected to the **Connect to GitHub** page and the installation ID is automatically populated.

1. Choose **Connect**.

1. Add a tag with the key `sagemaker` and value `true` to this CodeConnections connection.

1. Copy the connection ARN to save for later. You use the ARN as a parameter in the project creation step.

## Step 2: Create the Project
<a name="sagemaker-proejcts-walkthrough-create-3rdgit"></a>

In this step, you create a SageMaker AI MLOps project by using a SageMaker AI-provided project template to build, train, and deploy models.

**To create the SageMaker AI MLOps project**

1. Sign in to Studio. For more information, see [Amazon SageMaker AI domain overview](gs-studio-onboard.md).

1. In the Studio sidebar, choose the **Home** icon ( ![\[Black square icon representing a placeholder or empty image.\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/studio/icons/house.png)).

1. Select **Deployments** from the menu, and then select **Projects**.

1. Choose **Create project**.

   The **Create project** tab appears.

1. For **SageMaker AI project templates**, choose **Model building, training, and deployment with third-party Git repositories using CodePipeline**.

1. Choose **Next**.

1. Under **ModelBuild CodeRepository Info**, provide the following parameters:
   + For **Branch**, enter the branch to use from your Git repository for pipeline activities.
   + For **Full Repository Name**, enter the Git repository name in the format of *username/repository name* or *organization/repository name*.
   + For **Code Connection ARN**, enter the ARN of the CodeConnections connection you created in Step 1.

1. Under **ModelDeploy CodeRepository Info**, provide the following parameters:
   + For **Branch**, enter the branch to use from your Git repository for pipeline activities.
   + For **Full Repository Name**, enter the Git repository name in the format of *username/repository name* or *organization/repository name*.
   + For **Code Connection ARN**, enter the ARN of the CodeConnections connection you created in Step 1.

1. Choose **Create Project**.

The project appears in the **Projects** list with a **Status** of **Created**.

## Step 3: Make a Change in the Code
<a name="sagemaker-projects-walkthrough-change-3rdgit"></a>

Now make a change to the pipeline code that builds the model and commit the change to initiate a new pipeline run. The pipeline run registers a new model version.

**To make a code change**

1. In your model build GitHub repo, navigate to the `pipelines/abalone` folder. Double-click `pipeline.py` to open the code file.

1. In the `pipeline.py` file, find the line that sets the training instance type.

   ```
   training_instance_type = ParameterString(
           name="TrainingInstanceType", default_value="ml.m5.xlarge"
   ```

   Open the file for editing, change `ml.m5.xlarge` to `ml.m5.large`, then commit.

After you commit your code change, the MLOps system initiates a run of the pipeline that creates a new model version. In the next step, you approve the new model version to deploy it to production.

## Step 4: Approve the Model
<a name="sagemaker-proejcts-walkthrough-approve-3rdgit"></a>

Now you approve the new model version that was created in the previous step to initiate a deployment of the model version to a SageMaker AI endpoint.

**To approve the model version**

1. In the Studio Classic sidebar, choose the **Home** icon ( ![\[Black square icon representing a placeholder or empty image.\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/studio/icons/house.png)).

1. Select **Deployments** from the menu, and then select **Projects**.

1. Find the name of the project you created in the first step and double-click on it to open the project tab for your project.

1. In the project tab, choose **Model groups**, then double-click the name of the model group that appears.

   The model group tab appears.

1. In the model group tab, double-click **Version 1**. The **Version 1** tab opens. Choose **Update status**.

1. In the model **Update model version status** dialog box, in the **Status** dropdown list, select **Approve** and then choose **Update status**.

   Approving the model version causes the MLOps system to deploy the model to staging. To view the endpoint, choose the **Endpoints** tab on the project tab.

## (Optional) Step 5: Deploy the Model Version to Production
<a name="sagemaker-projects-walkthrough-prod-3rdgit"></a>

Now you can deploy the model version to the production environment.

**Note**  
To complete this step, you need to be an administrator in your Studio Classic domain. If you are not an administrator, skip this step.

**To deploy the model version to the production environment**

1. Log in to the CodePipeline console at [https://console.aws.amazon.com/codepipeline/](https://console.aws.amazon.com/codepipeline/)

1. Choose **Pipelines**, then choose the pipeline with the name **sagemaker-*projectname*-*projectid*-modeldeploy**, where *projectname* is the name of your project, and *projectid* is the ID of your project.

1. In the **DeployStaging** stage, choose **Review**.

1. In the **Review** dialog box, choose **Approve**.

   Approving the **DeployStaging** stage causes the MLOps system to deploy the model to production. To view the endpoint, choose the **Endpoints** tab on the project tab in Studio Classic.

## Step 6: Clean Up Resources
<a name="sagemaker-projectcts-walkthrough-cleanup-3rdgit"></a>

To stop incurring charges, clean up the resources that were created in this walkthrough.

**Note**  
To delete the CloudFormation stack and the Amazon S3 bucket, you need to be an administrator in Studio Classic. If you are not an administrator, ask your administrator to complete those steps.

1. In the Studio Classic sidebar, choose the **Home** icon ( ![\[Black square icon representing a placeholder or empty image.\]](http://docs.aws.amazon.com/sagemaker/latest/dg/images/studio/icons/house.png)).

1. Select **Deployments** from the menu, and then select **Projects**.

1. Select the target project from the dropdown list. If you don’t see your project, type the project name and apply the filter to find your project.

1. Select your project to view its details in the main panel.

1. Choose **Delete** from the **Actions** menu.

1. Confirm your choice by choosing **Delete** from the **Delete Project** window.

   This deletes the Service Catalog provisioned product that the project created. This includes the CodeCommit, CodePipeline, and CodeBuild resources created for the project.

1. Delete the CloudFormation stacks that the project created. There are two stacks, one for staging and one for production. The names of the stacks are **sagemaker-*projectname*-*project-id*-deploy-staging** and **sagemaker-*projectname*-*project-id*-deploy-prod**, where *projectname* is the name of your project, and *project-id* is the ID of your project.

   For information about how to delete a CloudFormation stack, see [Deleting a stack on the CloudFormation console](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-console-delete-stack.html) in the *CloudFormation User Guide*.

1. Delete the Amazon S3 bucket that the project created. The name of the bucket is **sagemaker-project-*project-id***, where *project-id* is the ID of your project.