翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
aws-apigateway-sagemakerendpoint
すべてのクラスは積極的に開発されており、将来のバージョンでは下位互換性がない変更または削除の対象となります。これらは、セマンティックバージョン管理
注意: 正しく機能するためには、プロジェクト内の AWS ソリューション構築パッケージと AWS CDK パッケージが同じバージョンである必要があります。
| 言語 | パッケージ |
|---|---|
|
aws_solutions_constructs.aws_apigateway_sagemakerendpoint
|
|
@aws-solutions-constructs/aws-apigateway-sagemakerendpoint
|
|
software.amazon.awsconstructs.services.apigatewaysagemakerendpoint
|
Overview
この AWS ソリューション構築物は、Amazon SageMaker エンドポイントに接続された Amazon API Gateway REST API を実装します。
TypeScript の最小限のデプロイ可能なパターン定義は次のとおりです。
import { ApiGatewayToSageMakerEndpoint, ApiGatewayToSageMakerEndpointProps } from '@aws-solutions-constructs/aws-apigateway-sagemakerendpoint'; // Below is an example VTL (Velocity Template Language) mapping template for mapping the Api GET request to the Sagemaker POST request const requestTemplate = `{ "instances": [ #set( $user_id = $input.params("user_id") ) #set( $items = $input.params("items") ) #foreach( $item in $items.split(",") ) {"in0": [$user_id], "in1": [$item]}#if( $foreach.hasNext ),#end $esc.newline #end ] }`; // Replace 'my-endpoint' with your Sagemaker Inference Endpoint new ApiGatewayToSageMakerEndpoint(this, 'test-apigw-sagemakerendpoint', { endpointName: 'my-endpoint', resourcePath: '{user_id}', requestMappingTemplate: requestTemplate });
Initializer
new ApiGatewayToSageMakerEndpoint(scope: Construct, id: string, props: ApiGatewayToSageMakerEndpointProps);
パラメータ
-
scope
Construct -
id
string
パターン構成プロパティ
| 名前 | タイプ | 説明 |
|---|---|---|
| ApigateWayProps? |
api.RestApiProps
|
API Gateway REST API のデフォルトの小道具をオーバーライドするオプションのユーザー提供の小道具です。 |
| ApigateWayExecutionRole? |
iam.Role
|
SageMaker エンドポイントを呼び出すために API Gateway で使用される IAM ロール。指定しない場合、デフォルトのロールはendpointName。 |
| EndpointName |
string
|
デプロイされた SageMaker 推論エンドポイントの名前。 |
| resourceName |
string
|
GET メソッドを使用できるオプションのリソース名。 |
| resourcePath |
string
|
GET メソッドのリソースパス。ここで定義された変数はrequestMappingTemplate。 |
| リクエストMappingTemplate |
string
|
REST API で受信した GET リクエストを SageMaker エンドポイントで期待される POST リクエストに変換するためのマッピングテンプレート。 |
| ResponseMappingTempl |
string
|
SageMaker エンドポイントから受信した応答を変換するためのオプションのマッピングテンプレート。 |
| LogGroupProps? |
logs.LogGroupProps
|
CloudWatch Logs ロググループのデフォルト小道具を上書きする、オプションのユーザー提供の小道具です。 |
パターンプロパティ
| 名前 | タイプ | 説明 |
|---|---|---|
| apigateway |
api.LambdaRestApi
|
パターンによって作成された API Gateway REST API のインスタンスを返します。 |
| APIGateWayRole |
iam.Role
|
API Gateway REST API のパターンによって作成された IAM ロールのインスタンスを返します。 |
| APIGatewayクラウドウォッチロール |
iam.Role
|
API Gateway REST API から CloudWatch へのアクセスロギングを有効にするパターンによって作成された IAM ロールのインスタンスを返します。 |
| APIGateWayLogGroup |
logs.LogGroup
|
API Gateway REST API アクセスログが送信されるパターンによって作成されたロググループのインスタンスを返します。 |
API の使用例
注意: 各 SageMaker エンドポイントは一意であり、API からの応答はデプロイされたモデルによって異なります。下記の例は、からのサンプルを想定していますこのブログ投稿
| 方法 | リクエストパス | クエリ文字列 | SageMaker アクション | 説明 |
|---|---|---|---|---|
| GET |
/321
|
items=101,131,162
|
sagemaker:InvokeEndpoint
|
特定のユーザーとアイテムの予測を取得します。 |
デフォルト設定
オーバーライドなしでこのパターンをすぐに実装すると、次のデフォルトが設定されます。
Amazon API Gateway
-
エッジ最適化 API エンドポイントのデプロイ
-
API Gateway での CloudWatch によるロギングの有効化
-
API Gateway の最小権限アクセス IAM ロールを設定する
-
すべての API メソッドのデフォルトの authorizationType を IAM に設定する
-
X-Ray トレースを有効にする
-
SageMaker にデータを渡す前にリクエストパラメータを検証する
Architecture
GitHub
| このパターンのコードを表示するには、問題を作成/表示し、プル要求などを行います。 | |
|---|---|
|
@aws-solutions-constructions/aws-apigateway-sagemakerendpoint |