Deploy to AWS

Run the kit on Amazon ECS or SageMaker.

mlflow offers two AWS kits. Both use the same container image, which you push to Amazon Elastic Container Registry (ECR). They differ in what runs the image. Download the kit from the Deploy anywhere tab of the Deploy & export panel, on the AWS ECS or AWS SageMaker card, then unzip it. The README.md inside has the commands below with your model's name and tag filled in. Read Choose where to deploy first if you have not downloaded a kit before.

You need the AWS CLI configured for your account and Docker installed. Placeholders in angle brackets, such as <REGION>, are yours to fill in. Nothing in the kit contains credentials.

Choose ECS or SageMaker

AWS ECSAWS SageMaker
What it isContainers on Amazon ECS with Fargate, so no servers to manageA managed SageMaker real-time endpoint
You call it withHTTP to a load balancer: POST /predictThe SageMaker runtime API: InvokeEndpoint
ScalingYou set the number of tasksYou set the instance type and count
AuthenticationYou add it at the load balancerAWS IAM signs every request
Choose it whenYou already run services on ECS, or want plain HTTPYou want IAM-based access and the SageMaker tooling

The service has no authentication of its own

Neither kit adds authentication to the container. On ECS, put an Application Load Balancer in front and authenticate there. On SageMaker, IAM controls who may invoke the endpoint. Do not expose the container directly to the internet.

Push the image to ECR

Both kits start the same way. Set your values, create a repository, log in, then build and push.

bash
export AWS_REGION=<REGION>
export AWS_ACCOUNT_ID=<AWS_ACCOUNT_ID>
export ECR=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com

aws ecr create-repository --repository-name my-model --region $AWS_REGION
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR
docker build -t $ECR/my-model:v-1 .
docker push $ECR/my-model:v-1

In the kit's README, my-model and v-1 are replaced by the image name and tag generated for your model. Use those, not the examples here.

Deploy on ECS

Edit the task definition

Open deploy/aws-ecs/task-definition.json and replace <AWS_ACCOUNT_ID> and <REGION>. The file describes one container with 1 vCPU and 2 GB of memory (cpu 1024, memory 2048), port 8080, a health check on /health, and logs sent to CloudWatch. It expects an execution role named ecsTaskExecutionRole. Change the name if your account uses a different one.

Register it

bash
aws logs create-log-group --log-group-name /ecs/my-model --region $AWS_REGION
aws ecs register-task-definition --cli-input-json file://deploy/aws-ecs/task-definition.json --region $AWS_REGION

Create the cluster and service

bash
aws ecs create-cluster --cluster-name my-model --region $AWS_REGION
aws ecs create-service --cluster my-model --service-name my-model \
  --task-definition my-model --desired-count 1 --launch-type FARGATE \
  --network-configuration "awsvpcConfiguration={subnets=[<SUBNET_ID>],securityGroups=[<SECURITY_GROUP_ID>],assignPublicIp=DISABLED}" \
  --region $AWS_REGION

The service gets no public IP address (assignPublicIp=DISABLED). Use private subnets with a NAT gateway, or ECR VPC endpoints, so the task can pull the image. Allow inbound TCP 8080 in the security group only from your load balancer.

To make the model reachable, create an Application Load Balancer with a target group on port 8080 and the health check path /health. The load balancer can end TLS and authenticate callers, for example with Amazon Cognito or an OIDC provider. Then add this line to create-service:

bash
  --load-balancers targetGroupArn=<TARGET_GROUP_ARN>,containerName=my-model,containerPort=8080

Deploy on SageMaker

The image follows the SageMaker container contract: it listens on port 8080, answers GET /ping, accepts POST /invocations with JSON records or CSV with a header row, and starts with the serve command.

bash
export ROLE_ARN=<SAGEMAKER_EXECUTION_ROLE_ARN>

aws sagemaker create-model --model-name my-model \
  --primary-container Image=$ECR/my-model:v-1 \
  --execution-role-arn $ROLE_ARN --region $AWS_REGION
aws sagemaker create-endpoint-config --endpoint-config-name my-model-config \
  --production-variants VariantName=AllTraffic,ModelName=my-model,InstanceType=ml.m5.large,InitialInstanceCount=1 \
  --region $AWS_REGION
aws sagemaker create-endpoint --endpoint-name my-model \
  --endpoint-config-name my-model-config --region $AWS_REGION
aws sagemaker wait endpoint-in-service --endpoint-name my-model --region $AWS_REGION

The execution role must be able to pull from ECR. The managed policy AmazonSageMakerFullAccess covers this. The kit uses one ml.m5.large instance as a starting point. Choose the size and count that suit your traffic. A running endpoint is billed until you delete it, so remove it when you are done:

bash
aws sagemaker delete-endpoint --endpoint-name my-model

Call the endpoint

The kit includes deploy/aws-sagemaker/sample-request.json, one record in the right shape.

bash
aws sagemaker-runtime invoke-endpoint --endpoint-name my-model \
  --content-type application/json --body fileb://deploy/aws-sagemaker/sample-request.json \
  --region $AWS_REGION out.json && cat out.json

Both return a predictions list. Classification models also return probabilities and classes. Requests are limited to 5 MB and 1,000 records, and SageMaker itself limits a request body to 6 MB. The full list of routes and errors is in Deploy with Docker.

Next steps

Updated 2026-11-22