# Automated deployment and replacement in Sagemaker
URL: https://docs.datarobot.com/en/docs/workbench/nxt-console/nxt-prediction-environments/nxt-prediction-environment-integrations/nxt-sagemaker-pred-env-integration.html

> Create a DataRobot-managed Sagemaker prediction environment to deploy and replace DataRobot custom models and Scoring Code in Sagemaker.

# Automated deployment and replacement in Sagemaker

> [!NOTE] Premium
> Automated deployment and replacement of custom models and Scoring Code in Sagemaker is a premium feature. Contact your DataRobot representative or administrator for information on enabling this feature.
> 
> Feature flag: Enable the Automated Deployment and Replacement of Custom Models in Sagemaker ( Premium feature)

Create a DataRobot-managed Sagemaker prediction environment to deploy custom models and Scoring Code in Sagemaker with real-time inference and serverless inference. With DataRobot management enabled, the external Sagemaker deployment has access to MLOps management, including automatic model replacement.

> [!NOTE] Service health information for external models and monitoring jobs
> Service health information is unavailable for external [agent-monitored deployments](https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/mlops-agent/monitoring-agent/index.html) and deployments with predictions uploaded through a [prediction monitoring job](https://docs.datarobot.com/en/docs/workbench/nxt-console/nxt-monitoring/nxt-monitoring-jobs.html).

## Create a Sagemaker prediction environment

To deploy a model in Sagemaker, first create a custom Sagemaker prediction environment:

1. Open theConsole > Prediction environmentspage and then click+ Add prediction environment.
2. In theAdd prediction environmentdialog box, configure the prediction environment settings:
3. In theManagement settings, select the relatedAWS Credentialsand specify aRegion. Once provided, DataRobot automatically fetches the available roles. Configure the following:
4. (Optional) To connect to and retrieve data from Amazon SQS for monitoring, in theMonitoring settingssection, clickEnable monitoringand configure theAWS Credentials,Region, andSQS Queuefields. You can optionally define aVisibility timeout(in seconds) to set how long the message persists before it is deleted from the SQS queue. You can also clickEnvironment variablesand then+ New environment variablesto add environment variables to the prediction environment.
5. After configuring the environment settings, clickAdd environment. The Sagemaker environment is now available from thePrediction environmentspage.

## Deploy a model to the Sagemaker prediction environment

Once you've created a Sagemaker prediction environment, you can deploy a model to it:

1. On theRegistry > Modelstab, in the table of registered models, click the registered model containing the version you want to deploy, opening the list of versions.
2. From the list of versions, click the custom model or Scoring Code enabled version you want to deploy, opening the registered model version panel.
3. In the upper-right corner of any tab in the registered model version panel, clickDeploy.
4. In thePrediction history and service healthsettings, underChoose prediction environment, clickChange.
5. In theSelect prediction environmentpanel, clickAWS Sagemaker, and then click the prediction environment you want to deploy to.
6. With a Sagemaker environment selected, in thePrediction history and service healthsection, set theReal-time inference instance typeandInitial instance countfields.
7. (Optional) Open theAdvanced environment settingsand define additionalEnvironment key-value pairsto provide extra parameters to the Sagemaker deployment interface.
8. Configure the remaining deployment settings. When deployment configuration is complete, clickDeploy model. Once the model is deployed to Sagemaker, you can use theScore your datacode snippet from thePredictions > Portable predictionstab to score data in Sagemaker.

## Restart a Sagemaker prediction environment

When you update database settings or credentials for the Sagemaker data connection used by the prediction environment, restart the environment to apply those changes to the environment:

1. ClickDeployments > Prediction environmentspage, and then select the Sagemaker prediction environment from the list.
2. Below the prediction environment settings, underService Account, clickRestart Environment.

---
