AWS::SageMaker::Endpoint - AWS CloudFormation
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

AWS::SageMaker::Endpoint

使用 AWS::SageMaker::Endpoint 资源可以通过请求中的指定配置来创建终端节点。Amazon SageMaker 使用终端节点来配置资源和部署模型。您可以使用 AWS::SageMaker::EndpointConfig 资源创建终端节点配置。有关更多信息,请参阅 Amazon SageMaker 开发人员指南 中的在 Amazon SageMaker 托管服务上部署模型

语法

要在 AWS CloudFormation 模板中声明此实体,请使用以下语法:

JSON

{ "Type" : "AWS::SageMaker::Endpoint", "Properties" : { "EndpointConfigName" : String, "EndpointName" : String, "ExcludeRetainedVariantProperties" : [ VariantProperty, ... ], "RetainAllVariantProperties" : Boolean, "Tags" : [ Tag, ... ] } }

YAML

Type: AWS::SageMaker::Endpoint Properties: EndpointConfigName: String EndpointName: String ExcludeRetainedVariantProperties: - VariantProperty RetainAllVariantProperties: Boolean Tags: - Tag

属性

EndpointConfigName

用于指定终端节点配置的 AWS::SageMaker::EndpointConfig 资源的名称。有关更多信息,请参阅 CreateEndpointConfig

必需:是

类型:字符串

最高63

模式^[a-zA-Z0-9](-*[a-zA-Z0-9])*

Update requires: No interruption

EndpointName

终端节点的名称。在 AWS 账户的 AWS 区域中,名称必须是唯一的。

必需:否

类型:字符串

最高63

模式^[a-zA-Z0-9](-*[a-zA-Z0-9])*

Update requires: Replacement

ExcludeRetainedVariantProperties

当您使用其值设置为 trueRetainAllVariantProperties 更新终端节点资源时,ExcludeRetainedVariantProperties 指定类型为 VariantProperty 的列表,使用由 EndpointConfig 提供的值进行覆盖。如果不为 ExcludeAllVariantProperties 指定值,则不覆盖任何变体属性。创建新终端节点资源或者将 RetainAllVariantProperties 设置为 false 时,请勿使用此属性。

必需:否

类型VariantProperty 列表

最高3

Update requires: No interruption

RetainAllVariantProperties

更新终端节点资源时,启用或禁用变体属性的保留,例如实例计数或变体权重。要在更新终端节点时保留其变体属性,请将 RetainAllVariantProperties 设置为 true。要在更新终端节点时使用在新 EndpointConfig 调用中指定的变体属性,请将 RetainAllVariantProperties 设置为 false。此属性仅在更新终端节点资源时使用,而不是在创建新终端节点资源时使用。

必需:否

类型:布尔值

Update requires: No interruption

Tags

要应用于此资源的键/值对的列表。

有关更多信息,请参阅 AWS 账单和成本管理用户指南 中的资源标签使用成本分配标签

必需:否

类型Tag 的列表

最高50

Update requires: No interruption

返回值

Ref

在将此资源的逻辑 ID 传递给内部 Ref 函数时,Ref 返回终端节点的 Amazon 资源名称 (ARN),例如 arn:aws:sagemaker:us-west-2:012345678901:endpoint/myendpoint

For more information about using the Ref function, see Ref.

Fn::GetAtt

Fn::GetAtt 内部函数返回此类型的一个指定属性的值。以下为可用属性和示例返回值。

有关使用 Fn::GetAtt 内部函数的更多信息,请参阅 Fn::GetAtt

Fn::GetAtt 返回一个此类型指定属性的值。以下为可用属性和示例返回值。

EndpointName

终端节点的名称,例如 MyEndpoint

示例

SageMaker 终端节点示例

以下示例从训练后的模型创建终端节点配置,然后创建一个终端节点。

JSON

{ "Description": "Basic Hosting entities test. We need models to create endpoint configs.", "Mappings": { "RegionMap": { "us-west-2": { "NullTransformer": "12345678901.dkr.ecr.us-west-2.amazonaws.com/mymodel:latest" }, "us-east-2": { "NullTransformer": "12345678901.dkr.ecr.us-east-2.amazonaws.com/mymodel:latest" }, "us-east-1": { "NullTransformer": "12345678901.dkr.ecr.us-east-1.amazonaws.com/mymodel:latest" }, "eu-west-1": { "NullTransformer": "12345678901.dkr.ecr.eu-west-1.amazonaws.com/mymodel:latest" }, "ap-northeast-1": { "NullTransformer": "12345678901.dkr.ecr.ap-northeast-1.amazonaws.com/mymodel:latest" }, "ap-northeast-2": { "NullTransformer": "12345678901.dkr.ecr.ap-northeast-2.amazonaws.com/mymodel:latest" }, "ap-southeast-2": { "NullTransformer": "12345678901.dkr.ecr.ap-southeast-2.amazonaws.com/mymodel:latest" }, "eu-central-1": { "NullTransformer": "12345678901.dkr.ecr.eu-central-1.amazonaws.com/mymodel:latest" } } }, "Resources": { "Endpoint": { "Type": "AWS::SageMaker::Endpoint", "Properties": { "EndpointConfigName": { "Fn::GetAtt" : ["EndpointConfig", "EndpointConfigName" ] } } }, "EndpointConfig": { "Type": "AWS::SageMaker::EndpointConfig", "Properties": { "ProductionVariants": [ { "InitialInstanceCount": 1, "InitialVariantWeight": 1, "InstanceType": "ml.t2.large", "ModelName": { "Fn::GetAtt" : ["Model", "ModelName" ] }, "VariantName": { "Fn::GetAtt" : ["Model", "ModelName" ] } } ] } }, "Model": { "Type": "AWS::SageMaker::Model", "Properties": { "PrimaryContainer": { "Image": { "Fn::FindInMap" : [ "AWS::Region", "NullTransformer"] } }, "ExecutionRoleArn": { "Fn::GetAtt" : [ "ExecutionRole", "Arn" ] } } }, "ExecutionRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "sagemaker.amazonaws.com" ] }, "Action": [ "sts:AssumeRole" ] } ] }, "Path": "/", "Policies": [ { "PolicyName": "root", "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "*", "Resource": "*" } ] } } ] } } }, "Outputs": { "EndpointId": { "Value": { "Ref" : "Endpoint" } }, "EndpointName": { "Value": { "Fn::GetAtt" : [ "Endpoint", "EndpointName" ] } } } }

YAML

Description: "Basic Hosting entities test. We need models to create endpoint configs." Mappings: RegionMap: "us-west-2": "NullTransformer": "123456789012.dkr.ecr.us-west-2.amazonaws.com/mymodel:latest" "us-east-2": "NullTransformer": "123456789012.dkr.ecr.us-east-2.amazonaws.com/mymodel:latest" "us-east-1": "NullTransformer": "123456789012.dkr.ecr.us-east-1.amazonaws.com/mymodel:latest" "eu-west-1": "NullTransformer": "123456789012.dkr.ecr.eu-west-1.amazonaws.com/mymodel:latest" "ap-northeast-1": "NullTransformer": "123456789012.dkr.ecr.ap-northeast-1.amazonaws.com/mymodel:latest" "ap-northeast-2": "NullTransformer": "123456789012.dkr.ecr.ap-northeast-2.amazonaws.com/mymodel:latest" "ap-southeast-2": "NullTransformer": "123456789012.dkr.ecr.ap-southeast-2.amazonaws.com/mymodel:latest" "eu-central-1": "NullTransformer": "123456789012.dkr.ecr.eu-central-1.amazonaws.com/mymodel:latest" Resources: Endpoint: Type: "AWS::SageMaker::Endpoint" Properties: EndpointConfigName: !GetAtt EndpointConfig.EndpointConfigName EndpointConfig: Type: "AWS::SageMaker::EndpointConfig" Properties: ProductionVariants: - InitialInstanceCount: 1 InitialVariantWeight: 1.0 InstanceType: ml.t2.large ModelName: !GetAtt Model.ModelName VariantName: !GetAtt Model.ModelName Model: Type: "AWS::SageMaker::Model" Properties: PrimaryContainer: Image: !FindInMap [RegionMap, !Ref "AWS::Region", "NullTransformer"] ExecutionRoleArn: !GetAtt ExecutionRole.Arn ExecutionRole: Type: "AWS::IAM::Role" Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Principal: Service: - "sagemaker.amazonaws.com" Action: - "sts:AssumeRole" Path: "/" Policies: - PolicyName: "root" PolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Action: "*" Resource: "*" Outputs: EndpointId: Value: !Ref Endpoint EndpointName: Value: !GetAtt Endpoint.EndpointName