Machine learning (ML) teams use MLflow to manage their ML lifecycle effectively. Amazon SageMaker MLflow provides comprehensive ML experiment tracking and model management capabilities. However, many enterprises have existing infrastructure requirements that need HTTPS-based integrations rather than direct SDK usage.
Many organizations need to integrate Amazon SageMaker MLflow with their established systems while maintaining their security and infrastructure patterns. This integration challenge affects teams who can’t use the SDK directly because of corporate security policies, network restrictions, or legacy system constraints.
In this post, we demonstrate how to build a secure Flask-based MLflow proxy service that provides HTTPS access to Amazon SageMaker MLflow without requiring the MLflow SDK. This solution is for organizations undergoing cloud transformation who want to preserve their existing ML workflows while adopting cloud-native services.
This post covers the following topics:
After implementing this solution, you can:
A lightweight Flask-based MLflow proxy architecture provides secure integration between enterprise systems and Amazon SageMaker MLflow through three key components.
Component 1: Application Load Balancer (ALB)
An AWS Application Load Balancer serves as the upstream router, providing the following:
Note: This implementation uses ALB, but you can alternatively use other routing solutions such as Nginx based on your requirements.
Component 2: Flask MLflow Proxy Service
At the heart of the architecture, a Python-based Flask application handles the following:
Component 3: Amazon SageMaker MLflow
The AWS managed SageMaker MLflow service provides the following:
This architecture provides secure communication while maintaining compatibility with existing enterprise systems. The proxy service acts as a bridge, transforming standard HTTPS requests into authenticated AWS API calls that can interact with SageMaker MLflow.
The following diagram shows how the Flask proxy service provides secure communication between external clients and Amazon SageMaker MLflow.

Figure 1: Architecture diagram showing the Flask proxy service integration with Amazon SageMaker MLflow
The architecture diagram shows three main components:
Let’s explore how requests flow through this architecture to provide secure MLflow access.
When a client initiates an HTTPS request, it first reaches the ALB, which acts as the entry point for all incoming traffic. The ALB then routes these requests to the MLflow proxy service.
When it receives the request, the MLflow proxy service performs several critical functions:
The MLflow proxy service transforms the incoming request into an authenticated AWS request before making the API call to SageMaker MLflow REST endpoints. After SageMaker MLflow processes the request, it returns a response which the MLflow proxy service processes and routes back to the original client.
This workflow maintains security while providing integration between enterprise systems and SageMaker MLflow.
To follow this walkthrough, make sure you have the following:
For information about AWS service pricing, see AWS Pricing Calculator.
This section walks you through deploying the solution in your AWS account and validating it. The deployment process takes approximately 40 minutes.
# Clone the repository
git clone https://github.com/aws-samples/sample-sagemaker-mlflow-rest-apis.git
# Navigate to project directory and install dependencies
cd sample-sagemaker-mlflow-rest-apis
npm ci
npx cdk bootstrap aws://<ACCOUNT_ID>/<REGION>
Deploy all the stacks with one of the following commands.
For tracking server based deployment:
npx cdk deploy --all --require-approval=never -c mlflowType=tracking
For serverless app based deployment:
npx cdk deploy --all --require-approval=never -c mlflowType=serverless
# Switch to root user
sudo su -
cd /root
# Install Python and dependencies
chmod +x install_python13.sh
./install_python13.sh
Note: This script is designed for Ubuntu-based systems. For other Linux distributions, install Python 3.12+, PIP3, and Virtualenv using your system’s package manager.
chmod +x setup_mlflow_proxy_app.sh
./setup_mlflow_proxy_app.sh
systemctl status mlflowproxy
Note: If the service isn’t running, check logs with the following command:
journalctl -u mlflowproxy
This section demonstrates how to interact with MLflow REST APIs through the ALB.
Note: These examples use the HTTP (unsecured) protocol. For production environments, we recommend HTTPS. We use curl to make the API requests in this post, but you can use any tool you prefer. The provided curl commands work identically for both tracking server and serverless modes; the proxy service handles the differences transparently.
aws cloudformation describe-stacks --stack-name sagemaker-infra-flaskapp-{mlflowType} --query 'Stacks[0].Outputs[?OutputKey==`ALBUrl`].OutputValue' --output text
<ALB DNS>, <EXP ID>, <RUN ID>, and <RUN NAME> with appropriate values.
curl -X POST http://<ALB DNS>/ajax-api/2.0/mlflow/experiments/create -H "Content-Type: application/json" -d '{"name": "mlflow-experiment"}'
curl -X POST http://<ALB DNS>/ajax-api/2.0/mlflow/experiments/search -H "Content-Type: application/json" -d '{"max_results": 5}'
curl -X GET 'http://<ALB DNS>/ajax-api/2.0/mlflow/experiments/get?experiment_id=0'
curl -X POST http://<ALB DNS>/ajax-api/2.0/mlflow/runs/create -H "Content-Type: application/json" -d '{"experiment_id": <EXP ID>, "run_name": "<RUN NAME>"}'
curl -X GET "http://<ALB DNS>/ajax-api/2.0/mlflow/artifacts/list?run_id=<RUN ID>"
curl -X POST "http://<ALB DNS>/ajax-api/2.0/mlflow/runs/set-tag" -H "Content-Type: application/json" -d '{"run_id": "<RUN ID>", "key": "model_type","value": "api-test"}'
curl -X POST http://<ALB DNS>/ajax-api/2.0/mlflow/runs/delete -H "Content-Type: application/json" -d '{"run_id": "<RUN ID>"}'
Note: You can also open the MLflow UI and view the changes you make using the preceding curl commands. For instructions on launching the MLflow UI, see Launch the MLflow UI using a presigned URL.
To avoid ongoing charges and remove the resources created by this solution, follow these cleanup steps:
npx cdk destroy --all -c mlflowType=tracking
For serverless app based deployment:
npx cdk destroy --all -c mlflowType=serverless
Note: The networking and SageMaker domain stacks are shared across both deployment modes. AWS CDK only deletes them when the last MLflow or Flask app stack pair is removed.
When you deploy this solution in a production environment, consider the following security measures:
These security measures help protect the Flask application against common web vulnerabilities and provide secure communication between components.
In this post, we showed how to build a secure Flask-based proxy service that provides HTTPS access to Amazon SageMaker MLflow. This solution helps organizations bridge their existing infrastructure with AWS managed MLflow capabilities while maintaining enterprise security requirements.
Solution benefits:
To learn more about Amazon SageMaker MLflow and related topics, you can:
Try this solution in your own environment and let us know your experience in the comments.
Manuel Rioux est fièrement propulsé par WordPress