REST API プロキシを用いたAmazon SageMaker MLflowへの外部アクセスの簡素化
AWS は、企業セキュリティポリシーやネットワーク制約により直接 SDK を使用できない環境向けに、Flask ベースの REST API プロキシを構築する手法を公開し、Amazon SageMaker MLflow の HTTPS アクセスを可能にする解決策を提示した。
キーポイント
セキュリティ要件への対応
企業の既存インフラやセキュリティポリシーにより直接 SDK を使用できない場合でも、HTTPS ベースのプロキシ経由で MLflow に安全にアクセスできる仕組みを提供する。
Flask による軽量プロキシ実装
AWS Application Load Balancer と Python の Flask アプリケーションを組み合わせたアーキテクチャにより、リクエストのインターセプト、認証管理、URL 変換を処理する。
IAM 認証とプレサイン機能
AWS Identity and Access Management (IAM) を活用した認証と URL プレサイン機能を統合することで、SDK に依存しない安全なアクセス制御を実現する。
CDKスタックによるリソースデプロイ
VPC、SageMaker ドメイン、MLflow サーバー(トラッキングまたはサーバーレス)、および Flask プロキシサービスの4つのCDKスタックを1コマンドで一括デプロイできます。
セッションマネージャーによるEC2接続
CloudFormation出力からEC2インスタンスIDを確認し、AWS Systems Manager Session Managerを使用して安全に接続します。
REST API を介した MLflow の統合
Flask ベースのプロキシサービスにより、ALB を通じて安全に MLflow REST API にアクセスでき、既存のワークフローへのマイグレーションが容易になります。
本番環境向けのセキュリティ対策
AWS WAF によるレート制限、内部 ALB の使用、および ACM を活用した HTTPS 終端など、企業向けに堅牢なセキュリティ構成を推奨しています。
影響分析・編集コメントを表示
影響分析
この記事は、クラウド移行を進める多くの企業が直面する「セキュリティ制約と新技術の導入」のジレンマに対する実用的な解決策を示しています。SDK の直接使用を前提としないアプローチにより、大規模企業や厳格なコンプライアンス環境における MLflow の採用障壁を下げ、ML 運用ライフサイクルの継続性を支える重要な役割を果たします。
編集コメント
SDK の直接使用が難しい大規模企業の現場にとって、このプロキシパターンは非常に実用的な解決策となるでしょう。セキュリティと柔軟性のバランスをどう取るかという課題に対し、具体的なコードレベルのアーキテクチャを示している点が評価できます。
機械学習 (ML) チームは、MLflow を用いて ML のライフサイクルを効果的に管理しています。Amazon SageMaker MLflow は、包括的な ML 実験の追跡およびモデル管理機能を提供します。しかし、多くの企業では、SDK の直接使用ではなく、HTTPS ベースの統合を必要とする既存のインフラ要件を持っています。
多くの組織は、セキュリティやインフラのパターンを維持しながら、Amazon SageMaker MLflow を既存システムと統合する必要があります。この統合課題は、企業のセキュリティポリシー、ネットワーク制限、またはレガシーシステムの制約により SDK を直接使用できないチームに影響を与えます。
本稿では、MLflow SDK の使用を必要とせずに Amazon SageMaker MLflow への HTTPS アクセスを提供する、安全な Flask ベースの MLflow プロキシサービスの構築方法を実演します。このソリューションは、既存の ML ワークフローを維持しつつクラウドネイティブサービスを採用したい、クラウド変革を進めている組織向けです。
本稿では以下のトピックを取り上げます:
- MLflow の HTTPS リクエスト用の MLflow プロキシサービスの実装。
- 安全なアクセスのための AWS Identity and Access Management (IAM) 認証の構成。
- URL プレサインおよびリクエスト変換の管理。
このソリューションを実装することで、以下が可能になります:
- 標準的な HTTPS エンドポイントを通じて、SageMaker MLflow を安全にアクセスできます。
- お使いの組織のセキュリティ要件への準拠を維持します。
- MLflow を既存のエンタープライズシステムと統合します。
- 実装の複雑さとメンテナンスオーバーヘッドを削減します。
ソリューション概要
軽量な Flask ベースの MLflow プロキシアーキテクチャは、3 つの主要コンポーネントを通じて、エンタープライズシステムと Amazon SageMaker MLflow の間の安全な統合を提供します。
コンポーネント 1: アプリケーションロードバランサー (ALB)
AWS Application Load Balancer はアップストリームルーターとして機能し、以下の機能を提供します:
- MLflow UI および REST API リクエストのトラフィック分散。
- 初期リクエストの処理とルーティング。
- カスタムドメイン名および SSL 終端のサポート。
注: この実装では ALB を使用していますが、要件に応じて Nginx ベースなどの他のルーティングソリューションを使用することも可能です。
コンポーネント 2: Flask MLflow プロキシサービス
アーキテクチャの中核となる Python ベースの Flask アプリケーションは、以下の処理を担当します:
- 着信 HTTPS リクエストのインターセプトと処理。
- AWS 認証およびリクエスト署名の管理。
- セキュアな MLflow エンドポイントアクセスのための URL 変換。
- クライアントへのレスポンスルーティングの処理。
コンポーネント 3: Amazon SageMaker MLflow
AWS マネージドの SageMaker MLflow サービスは、以下の機能を提供します:
- MLflow の 2 つのデプロイモードへの対応:
MLflow Tracking Server – 管理された MLflow トラッキングサーバー。
- MLflowApp – サーバーレス MLflow アプリケーション。
- 追跡情報のためのバックエンドメタデータストア。
- モデルファイルおよびデータのストレージ。
このアーキテクチャは、既存のエンタープライズシステムとの互換性を維持しつつ、安全な通信を提供します。プロキシサービスは橋渡し役として機能し、標準的な HTTPS リクエストを認証された AWS API 呼び出しに変換して、SageMaker MLflow と対話できるようにします。
アーキテクチャとリクエストワークフロー
以下の図は、Flask プロキシサービスが外部クライアントと Amazon SageMaker MLflow の間で安全な通信を提供する方法を示しています。

*図 1: Amazon SageMaker MLflow と Flask プロキシサービスの統合を示すアーキテクチャ図*
アーキテクチャ図には、3 つの主要コンポーネントが表示されています:
- 着信トラフィックを処理する ALB (Application Load Balancer)。
- 認証とリクエスト変換を管理する Flask プロキシサービス。
- ML 操作を処理する Amazon SageMaker MLflow。
リクエストワークフロー
このアーキテクチャを通じて、安全な MLflow アクセスがどのように提供されるか、リクエストの流れを見てみましょう。
クライアントが HTTPS リクエストを開始すると、まずすべての着信トラフィックのエントリーポイントとして機能する ALB に到達します。その後、ALB はこれらのリクエストを MLflow プロキシサービスにルーティングします。
リクエストを受信すると、MLflow プロキシサービスは以下の重要な機能を実行します:
- AWS IAM 連携による認証処理を行います。
- URL を変換し、安全なアクセスのために事前署名を付与します。
- 必要に応じて MLflow REST API エンドポイントを処理します。
MLflow プロキシサービスは、SageMaker MLflow の REST エンドポイントに対して API コールを行う前に、受信したリクエストを認証付きの AWS リクエストに変換します。SageMaker MLflow がリクエストを処理した後、応答が返されますが、これは MLflow プロキシサービスによって再度処理され、元のクライアントへルーティングされます。
このワークフローは、エンタープライズシステムと SageMaker MLflow の間の統合を提供しつつ、セキュリティを維持します。
前提条件
このウォークスルーを進めるには、以下の準備が必要です:
- AWS アカウント。
- 以下のツールがインストールされたワークステーション:
以下を作成する権限を設定した AWS Command Line Interface (AWS CLI):
Amazon Virtual Private Cloud (Amazon VPC) および関連するネットワークコンポーネント。
- Amazon Elastic Compute Cloud (Amazon EC2) インスタンス。
- Amazon SageMaker AI リソース。
- Amazon Simple Storage Service (Amazon S3) バケット。
- AWS Identity and Access Management (IAM) ロールおよびポリシー。
- AWS CloudFormation スacks。
- AWS Application Load Balancers。
- Node.js バージョン 18.0.0 以降。
- NPM。
- AWS Cloud Development Kit (AWS CDK) CLI バージョン 2.100.0 以降。
- pip または pip3 を備えた Python 3.x。
- 必要な知識:
AWS サービスおよび IAM 権限に関する基本的な理解。
- Python および Flask アプリケーションへの慣れ。
- MLflow の概念と運用に関する理解。
- コストに関する考慮事項:
このソリューションは、コストが発生する可能性のある AWS リソースを作成します。
- 主要なコスト要因となるリソースには以下が含まれます:
Amazon EC2 インスタンス。
- Application Load Balancer。
- Amazon SageMaker AI リソース。
- Amazon S3 ストレージ。
AWS サービスの価格に関する情報は、AWS Pricing Calculator をご覧ください。
ソリューションのデプロイ
このセクションでは、AWS アカウント内でソリューションをデプロイし、検証する方法について順を追って説明します。デプロイプロセスには約 40 分かかります。
ステップ 1: AWS CDK を使用してインフラストラクチャをデプロイする
- ソリューションコードをダウンロードし、依存関係をインストールします:
# リポジトリをクローン
git clone https://github.com/aws-samples/sample-sagemaker-mlflow-rest-apis.git
プロジェクトディレクトリに移動して依存関係をインストール
cd sample-sagemaker-mlflow-rest-apis
npm ci
- AWS CDK 用に環境をブートストラップします。AWS アカウントとリージョンがすでに AWS CDK 用にブートストラップされている場合は、このステップはスキップしてください。
CDK のために AWS アカウントとリージョンをブートストラップ:
npx cdk bootstrap aws:///
- AWS アカウントに必要なリソースをデプロイします。本ソリューションは 4 つの CDK スタックで構成されています:
ネットワーキングスタック — VPC およびネットワークコンポーネントを作成します。
SageMaker AI ドメインスタック — SageMaker ドメインを設定します。
SageMaker MLflow スタック — MLflow 追跡サーバーまたは MLflow サーバーレスアプリをデプロイします。
Flask アプリケーションスタック — MLflow プロキシサービス(proxy service)をデプロイします。
以下のいずれかのコマンドを使用して、すべてのスタックをデプロイしてください。
追跡サーバーベースのデプロイの場合:
npx cdk deploy --all --require-approval=never -c mlflowType=tracking
サーバーレスアプリベースのデプロイの場合:
npx cdk deploy --all --require-approval=never -c mlflowType=serverless
ステップ 2: Flask MLflow プロキシサービスのインストールと設定
- EC2 インスタンスへの接続:
CDK の出力、または sagemaker-infra-flaskapp-{mlflowType} AWS CloudFormation スタックの出力セクションから Amazon EC2 インスタンス ID を確認してください。
- AWS Systems Manager Session Manager を使用して接続します。Session Manager 接続ガイドに従ってください。
- Python 3.13 と依存関係、および必要なパッケージをインストールします:
# ルートユーザーに切り替え
sudo su -
cd /root
Python と依存関係をインストール
chmod +x install_python13.sh
./install_python13.sh
注: このスクリプトは Ubuntu ベースのシステム向けに設計されています。他の Linux ディストリビューションの場合は、システムのパッケージマネージャーを使用して Python 3.12 以上、PIP3、および Virtualenv をインストールしてください。
- MLflow プロキシサービスをインストールして起動します:
chmod +x setup_mlflow_proxy_app.sh
./setup_mlflow_proxy_app.sh
- Flask MLflow プロキシサービスのステータスを確認します:
systemctl status mlflowproxy
注: サービスが実行されていない場合は、以下のコマンドでログを確認してください:
journalctl -u mlflowproxy
ステップ 3: MLflow REST API アクセスの検証
このセクションでは、ALB を介して MLflow REST APIs と対話する方法を示します。
*注意:これらの例では HTTP(非暗号化)プロトコルを使用しています。本番環境では HTTPS の使用を推奨します。本記事では API リクエストに curl を使用していますが、お好みのツールをご利用いただけます。提供された curl コマンドは、トラッキングサーバーモードとサーバーレスモードの両方で同じように機能し、プロキシサービスが違いを透過的に処理します。*
- ご自身のワークステーションで以下のコマンドを実行して、ALB の DNS 名を取得してください:
aws cloudformation describe-stacks --stack-name sagemaker-infra-flaskapp-{mlflowType} --query 'Stacks[0].Outputs[?OutputKey==ALBUrl].OutputValue' --output text
- ご自身のワークステーションで以下のコマンドを実行して、MLflow API エンドポイントのテストを行ってください。 , , , および を適切な値に置き換えてください。
実験の作成:
curl -X POST http:///ajax-api/2.0/mlflow/experiments/create -H "Content-Type: application/json" -d '{"name": "mlflow-experiment"}'
- 実験の検索:
curl -X POST http:///ajax-api/2.0/mlflow/experiments/search -H "Content-Type: application/json" -d '{"max_results": 5}'
- 実験の取得:
curl -X GET 'http:///ajax-api/2.0/mlflow/experiments/get?experiment_id=0'
- 実験内のランの実行:
curl -X POST http:///ajax-api/2.0/mlflow/runs/create -H "Content-Type: application/json" -d '{"experiment_id": , "run_name": ""}'
- ランからのアーティファクトのリスト表示:
curl -X GET "http:///ajax-api/2.0/mlflow/artifacts/list?run_id="
- ランへのタグ設定:
curl -X POST "http:///ajax-api/2.0/mlflow/runs/set-tag" -H "Content-Type: application/json" -d '{"run_id": "", "key": "model_type","value": "api-test"}'
- ランの削除:
curl -X POST http:///ajax-api/2.0/mlflow/runs/delete -H "Content-Type: application/json" -d '{"run_id": ""}'
*注意:MLflow UI を開き、前述の curl コマンドを使用して行った変更を確認することもできます。MLflow UI の起動方法については、プレサイン URL を使用した MLflow UI の起動を参照してください。*
クリーンアップ
継続的な課金を避け、このソリューションによって作成されたリソースを削除するには、以下のクリーンアップ手順に従ってください:
- CDK 管理リソースの削除。ワークステーション上のクローンしたリポジトリのルートディレクトリに移動し、以下を実行してください。
追跡サーバーベースのデプロイの場合:
npx cdk destroy --all -c mlflowType=tracking
サーバーレスアプリベースのデプロイの場合:
npx cdk destroy --all -c mlflowType=serverless
注: ネットワーキングおよび SageMaker ドメインスタックは、両方のデプロイモードで共有されています。AWS CDK は、最後の MLflow または Flask アプリスタックペアが削除された場合にのみ、これらを削除します。
- 手動リソースのクリーンアップ。保持ポリシーや依存関係のため、一部のリソースを手動で削除する必要がある場合があります:
Amazon S3 バケット:
Amazon S3 コンソールに移動してください。
- このソリューションによって作成されたバケットを特定します。
- 各バケットの中身を空にし、削除します。
- Amazon CloudWatch ロググループ:
CloudWatch コンソールで、このソリューションに関連付けられたロググループを検索します。
- これらのロググループを削除します。
- Flask ベースのプロキシサービスに対して Amazon CloudWatch の監視を構成し、アプリケーションの健全性を追跡し、異常を検出し、不審な活動に対するアラートを設定します。
- 潜在的なサービス拒否 (DoS) アタックから保護し、個々のクライアントからのリクエスト数を制御するために、Flask ベースのプロキシサービスに対してレート制限を実装します。AWS WAF(ウェブアプリケーションファイアウォール)を ALB と併用して、レートベースルールを実装できます。
- プロキシアクセスをプライベートネットワークに制限するため、内部(インターネット非公開)ALB をデプロイします。この設定により、VPC 内または接続されたネットワークからのトラフィックのみがサービスに到達できるようになります。VPC ピアリングまたは AWS Transit Gateway を通じて接続します。
- クライアントとアプリケーション間の安全な通信のために、ALB レベルで HTTPS 終端を有効化します。AWS Certificate Manager (ACM) を使用して、アプリケーション用の SSL/TLS 証明書のプロビジョニングおよび管理を行うことができます。HTTPS リスナーの構成に関する手順については、Application Load Balancer の HTTPS リスナードキュメントを参照してください。
これらのセキュリティ対策は、一般的な Web 脆弱性から Flask アプリケーションを保護し、コンポーネント間の安全な通信を提供します。
結論
本記事では、Amazon SageMaker MLflow への HTTPS アクセスを提供する安全な Flask ベースのプロキシサービスの構築方法について紹介しました。このソリューションは、既存のインフラストラクチャと AWS マネージド MLflow の機能を橋渡ししながら、エンタープライズのセキュリティ要件を維持することを組織に支援します。
ソリューションのメリット:
- 既存のエンタープライズセキュリティコントロールとの統合。
- 既存の ML ワークフローへの最小限の変更。
- デプロイメントの複雑さの低減。
- REST API の統合。
- エンタープライズプロキシサービスとの互換性。
次のステップ
Amazon SageMaker MLflow および関連トピックについてさらに詳しく知りたい場合は、以下を実行できます:
- Amazon SageMaker MLflow のドキュメントを参照する。
- MLflow 追跡サーバーおよび MLflow アプリケーションに関する記事を読む。
このソリューションをご自身の環境でお試しください。その経験をコメント欄でお知らせください。
執筆者について

Manish Garg
Manish は AWS Professional Services のデリバリーコンサルタントであり、AWS Cloud 上での顧客ワークロードの移行と近代化を専門としています。彼は技術に対する深い情熱を持ち、DevOps プラクティスの分野にも強い関心を寄せています。
原文を表示
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:
- Implementing the MLflow proxy service for MLflow HTTPS requests.
- Configuring AWS Identity and Access Management (IAM) authentication for secure access.
- Managing URL pre-signing and request transformation.
After implementing this solution, you can:
- Access SageMaker MLflow securely through standard HTTPS endpoints.
- Maintain compliance with your organization’s security requirements.
- Integrate MLflow with existing enterprise systems.
- Reduce implementation complexity and maintenance overhead.
Solution overview
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:
- Traffic distribution for MLflow UI and REST API requests.
- Initial request handling and routing.
- Support for custom domain names and SSL termination.
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:
- Intercepting and processing incoming HTTPS requests.
- Managing AWS authentication and request signing.
- Transforming URLs for secure MLflow endpoint access.
- Handling response routing back to clients.
Component 3: Amazon SageMaker MLflow
The AWS managed SageMaker MLflow service provides the following:
- Support for two MLflow deployment modes:
MLflow Tracking Server – managed MLflow tracking server.
- MLflowApp – serverless MLflow application.
- Backend metadata store for tracking information.
- Storage for model files and data.
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.
Architecture and request workflow
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:
- An ALB that handles incoming traffic.
- A Flask proxy service that manages authentication and request transformation.
- Amazon SageMaker MLflow that processes ML operations.
Request workflow
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:
- Handles authentication through AWS IAM integration.
- Transforms URLs and pre-signs them for secure access.
- Processes the MLflow REST API endpoints as needed.
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.
Prerequisites
To follow this walkthrough, make sure you have the following:
- An AWS account.
- A workstation with the following tools installed:
AWS Command Line Interface (AWS CLI) configured with permissions to create:
Amazon Virtual Private Cloud (Amazon VPC) and associated networking components.
- Amazon Elastic Compute Cloud (Amazon EC2) instances.
- Amazon SageMaker AI resources.
- Amazon Simple Storage Service (Amazon S3) buckets.
- AWS Identity and Access Management (IAM) roles and policies.
- AWS CloudFormation stacks.
- AWS Application Load Balancers.
- Node.js version 18.0.0 or later.
- NPM.
- AWS Cloud Development Kit (AWS CDK) CLI version 2.100.0 or later.
- Python 3.x with pip or pip3.
- Required knowledge:
Basic understanding of AWS services and IAM permissions.
- Familiarity with Python and Flask applications.
- Understanding of MLflow concepts and operations.
- Cost considerations:
This solution creates AWS resources that might incur costs.
- Key cost-driving resources include:
Amazon EC2 instances.
- Application Load Balancer.
- Amazon SageMaker AI resources.
- Amazon S3 storage.
For information about AWS service pricing, see AWS Pricing Calculator.
Deploy the solution
This section walks you through deploying the solution in your AWS account and validating it. The deployment process takes approximately 40 minutes.
Step 1: Deploy the infrastructure using AWS CDK
- Download the solution code and install dependencies:
# 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- Bootstrap your environment for AWS CDK. Skip this step if your AWS account and Region are already bootstrapped for AWS CDK.Bootstrap the AWS account and Region for CDK:
npx cdk bootstrap aws:///- Deploy the required resources on your AWS account.The solution consists of four CDK stacks:
Networking stack — creates the VPC and networking components.
- SageMaker AI domain stack — sets up the SageMaker domain.
- SageMaker MLflow stack — deploys the MLflow tracking server or MLflow serverless app.
- Flask application stack — deploys the MLflow proxy service.
Deploy all the stacks with one of the following commands.
For tracking server based deployment:
npx cdk deploy --all --require-approval=never -c mlflowType=trackingFor serverless app based deployment:
npx cdk deploy --all --require-approval=never -c mlflowType=serverlessStep 2: Install and configure the Flask MLflow proxy service
- Connect to the EC2 instance:
Note the Amazon EC2 instance ID from the CDK output or from the sagemaker-infra-flaskapp-{mlflowType} AWS CloudFormation stack output section.
- Use AWS Systems Manager Session Manager to connect. Follow the Session Manager connection guide.
- Install Python 3.13 and dependencies.Install Python packages:
# Switch to root user
sudo su -
cd /root
# Install Python and dependencies
chmod +x install_python13.sh
./install_python13.shNote: 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.
- Install and start the MLflow proxy service:
chmod +x setup_mlflow_proxy_app.sh
./setup_mlflow_proxy_app.sh- Check the Flask MLflow proxy service status:
systemctl status mlflowproxyNote: If the service isn’t running, check logs with the following command:
journalctl -u mlflowproxyStep 3: Validate MLflow REST API access
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.*
- Get your ALB DNS name by running the following command on your workstation:
aws cloudformation describe-stacks --stack-name sagemaker-infra-flaskapp-{mlflowType} --query 'Stacks[0].Outputs[?OutputKey==`ALBUrl`].OutputValue' --output text- Test MLflow API endpoints by running the following commands on your workstation. Replace , , , and with appropriate values.
Create an experiment:
curl -X POST http:///ajax-api/2.0/mlflow/experiments/create -H "Content-Type: application/json" -d '{"name": "mlflow-experiment"}'- Search experiments:
curl -X POST http:///ajax-api/2.0/mlflow/experiments/search -H "Content-Type: application/json" -d '{"max_results": 5}'- Get an experiment:
curl -X GET 'http:///ajax-api/2.0/mlflow/experiments/get?experiment_id=0'- Create a run inside an experiment:
curl -X POST http:///ajax-api/2.0/mlflow/runs/create -H "Content-Type: application/json" -d '{"experiment_id": , "run_name": ""}'- List artifacts from a run:
curl -X GET "http:///ajax-api/2.0/mlflow/artifacts/list?run_id="- Set a tag on a run:
curl -X POST "http:///ajax-api/2.0/mlflow/runs/set-tag" -H "Content-Type: application/json" -d '{"run_id": "", "key": "model_type","value": "api-test"}'- Delete a run:
curl -X POST http:///ajax-api/2.0/mlflow/runs/delete -H "Content-Type: application/json" -d '{"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.*
Cleanup
To avoid ongoing charges and remove the resources created by this solution, follow these cleanup steps:
- Delete CDK-managed resources.Navigate to the root directory of the cloned repository on your workstation and run the following.For tracking server based deployment:
npx cdk destroy --all -c mlflowType=trackingFor serverless app based deployment:
npx cdk destroy --all -c mlflowType=serverlessNote: 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.
- Manual resource cleanup. Some resources might require manual deletion because of retention policies or dependencies:
Amazon S3 buckets:
Navigate to the Amazon S3 console.
- Identify the buckets created by this solution.
- Empty each bucket and delete it.
- Amazon CloudWatch log groups:
In the CloudWatch console, find the log groups associated with this solution.
- Delete these log groups.
Security considerations
When you deploy this solution in a production environment, consider the following security measures:
- Configure Amazon CloudWatch monitoring for the Flask-based proxy service to track application health, detect anomalies, and set up alerts for suspicious activities.
- Implement rate limiting for the Flask-based proxy service to protect against potential denial-of-service (DoS) attacks and control the number of requests from individual clients. You can use AWS WAF (web application firewall) with the ALB to implement rate-based rules.
- Deploy an internal (non-internet-facing) ALB to restrict proxy access to your private network. This setup makes sure that only traffic from within your VPC or connected networks can reach the service. Connect through VPC peering or AWS Transit Gateway.
- Enable HTTPS termination at the ALB level for secure communication between clients and your application. You can use AWS Certificate Manager (ACM) to provision and manage SSL/TLS certificates for your application. For instructions on configuring HTTPS listeners, see the Application Load Balancer HTTPS listeners documentation.
These security measures help protect the Flask application against common web vulnerabilities and provide secure communication between components.
Conclusion
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:
- Integration with existing enterprise security controls.
- Minimal changes to existing ML workflows.
- Reduced deployment complexity.
- REST API integration.
- Compatibility with enterprise proxy services.
Next steps
To learn more about Amazon SageMaker MLflow and related topics, you can:
- Explore the Amazon SageMaker MLflow documentation.
- Read about MLflow tracking servers and MLflow apps.
Try this solution in your own environment and let us know your experience in the comments.
About the authors

Manish Garg
Manish is a Delivery Consultant with AWS Professional Services, specializing in migrating and modernizing customer workloads on the AWS Cloud. He possesses a profound enthusiasm for technology, coupled with a keen interest in the realms of DevOps practices.
関連記事
埋め込み型 Amazon SageMaker AI MLflow アプリをカスタムポータルに構築する方法
AWS は、大規模な機械学習チーム向けに、SSO を統合した内部ポータルへ Amazon SageMaker AI の MLflow アプリを安全かつスケーラブルに埋め込む手法を発表しました。
Amazon SageMaker AI で MLflow v3.10 がサポートされ、生成 AI 開発が効率化
Amazon は Amazon SageMaker AI の MLflow Apps にバージョン 3.10 を導入し、生成 AI 開発のワークフローを簡素化し、実験追跡機能を強化したと発表した。
Amazon SageMaker AI LLM推論における包括的な観測可能性:GPU利用率からLLM品質まで
AWSは、大規模言語モデル(LLM)をAmazon SageMaker AI Inferenceでスケール展開する際、従来のソフトウェアとは異なる不確実な出力に対応するため、GPU利用率やLLMの品質変化を追跡する包括的な観測可能性の重要性について解説した。