Skip to content

create_endpoint_config

create_endpoint_config(
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    endpoint_config_name: Optional[EndpointConfigName] = None,
    production_variants: Optional[ProductionVariantList] = None,
    data_capture_config: Optional[DataCaptureConfig] = None,
    tags: Optional[TagList] = None,
    kms_key_id: Optional[KmsKeyId] = None,
    async_inference_config: Optional[AsyncInferenceConfig] = None,
    explainer_config: Optional[ExplainerConfig] = None,
    shadow_production_variants: Optional[ProductionVariantList] = None,
    execution_role_arn: Optional[RoleArn] = None,
    vpc_config: Optional[VpcConfig] = None,
    enable_network_isolation: Optional[Boolean] = None,
    metrics_config: Optional[MetricsConfig] = None,
) -> CreateEndpointConfigOutput

Creates an endpoint configuration that SageMaker hosting services uses to deploy models. In the configuration, you identify one or more models, created using the CreateModel API, to deploy and the resources that you want SageMaker to provision. Then you call the CreateEndpoint API.

Use this API if you want to use SageMaker hosting services to deploy models into production.

In the request, you define a ProductionVariant, for each model that you want to deploy. Each ProductionVariant parameter also describes the resources that you want SageMaker to provision. This includes the number and type of ML compute instances to deploy.

If you are hosting multiple models, you also assign a VariantWeight to specify how much traffic you want to allocate to each model. For example, suppose that you want to host two models, A and B, and you assign traffic weight 2 for model A and 1 for model B. SageMaker distributes two-thirds of the traffic to Model A, and one-third to model B.

When you call CreateEndpoint, a load call is made to DynamoDB to verify that your endpoint configuration exists. When you read data from a DynamoDB table supporting Eventually Consistent Reads , the response might not reflect the results of a recently completed write operation. The response might include some stale data. If the dependent entities are not yet in DynamoDB, this causes a validation error. If you repeat your read request after a short time, the response should return the latest data. So retry logic is recommended to handle these possible issues. We also recommend that customers call DescribeEndpointConfig before calling CreateEndpoint to minimize the potential impact of a DynamoDB eventually consistent read.

Parameters:

  • endpoint_config_name (Optional[EndpointConfigName], default: None ) –

    The name of the endpoint configuration. You specify this name in a CreateEndpoint request.

  • production_variants (Optional[ProductionVariantList], default: None ) –

    An array of ProductionVariant objects, one for each model that you want to host at this endpoint.

  • tags (Optional[TagList], default: None ) –

    An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in different ways, for example, by purpose, owner, or environment. For more information, see Tagging Amazon Web Services Resources.

  • kms_key_id (Optional[KmsKeyId], default: None ) –

    The Amazon Resource Name (ARN) of a Amazon Web Services Key Management Service key that SageMaker uses to encrypt data on the storage volume attached to the ML compute instance that hosts the endpoint.

    The KmsKeyId can be any of the following formats:

    • Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab

    • Key ARN: arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab

    • Alias name: alias/ExampleAlias

    • Alias name ARN: arn:aws:kms:us-west-2:111122223333:alias/ExampleAlias

    The KMS key policy must grant permission to the IAM role that you specify in your CreateEndpoint, UpdateEndpoint requests. For more information, refer to the Amazon Web Services Key Management Service section Using Key Policies in Amazon Web Services KMS

    Certain Nitro-based instances include local storage, dependent on the instance type. Local storage volumes are encrypted using a hardware module on the instance. If any of the models that you specify in the ProductionVariants parameter use nitro-based instances with local storage, the KmsKeyId parameter does not encrypt instance local storage.

    For a list of instance types that support local instance storage, see Instance Store Volumes.

    For more information about local instance storage encryption, see SSD Instance Store Volumes.

  • async_inference_config (Optional[AsyncInferenceConfig], default: None ) –

    Specifies configuration for how an endpoint performs asynchronous inference. This is a required field in order for your Endpoint to be invoked using InvokeEndpointAsync.

  • explainer_config (Optional[ExplainerConfig], default: None ) –

    A member of CreateEndpointConfig that enables explainers.

  • shadow_production_variants (Optional[ProductionVariantList], default: None ) –

    An array of ProductionVariant objects, one for each model that you want to host at this endpoint in shadow mode with production traffic replicated from the model specified on ProductionVariants. If you use this field, you can only specify one variant for ProductionVariants and one variant for ShadowProductionVariants.

  • execution_role_arn (Optional[RoleArn], default: None ) –

    The Amazon Resource Name (ARN) of an IAM role that Amazon SageMaker AI can assume to perform actions on your behalf. For more information, see SageMaker AI Roles.

    To be able to pass this role to Amazon SageMaker AI, the caller of this action must have the iam:PassRole permission.

  • enable_network_isolation (Optional[Boolean], default: None ) –

    Sets whether all model containers deployed to the endpoint are isolated. If they are, no inbound or outbound network calls can be made to or from the model containers.

  • metrics_config (Optional[MetricsConfig], default: None ) –

    The configuration parameters for utilization metrics.

Raises:

  • ResourceLimitExceeded –

    You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_sagemaker/_services/sage_maker.py
def create_endpoint_config(
    self,
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    endpoint_config_name: Optional[
        "capo_sagemaker.types.endpoint_config_name.EndpointConfigName"
    ] = None,
    production_variants: Optional[
        "capo_sagemaker.types.production_variant_list.ProductionVariantList"
    ] = None,
    data_capture_config: Optional[
        "capo_sagemaker.types.data_capture_config.DataCaptureConfig"
    ] = None,
    tags: Optional["capo_sagemaker.types.tag_list.TagList"] = None,
    kms_key_id: Optional["capo_sagemaker.types.kms_key_id.KmsKeyId"] = None,
    async_inference_config: Optional[
        "capo_sagemaker.types.async_inference_config.AsyncInferenceConfig"
    ] = None,
    explainer_config: Optional[
        "capo_sagemaker.types.explainer_config.ExplainerConfig"
    ] = None,
    shadow_production_variants: Optional[
        "capo_sagemaker.types.production_variant_list.ProductionVariantList"
    ] = None,
    execution_role_arn: Optional["capo_sagemaker.types.role_arn.RoleArn"] = None,
    vpc_config: Optional["capo_sagemaker.types.vpc_config.VpcConfig"] = None,
    enable_network_isolation: Optional[
        "capo_sagemaker.types.boolean.Boolean"
    ] = None,
    metrics_config: Optional[
        "capo_sagemaker.types.metrics_config.MetricsConfig"
    ] = None,
) -> (
    "capo_sagemaker.types.create_endpoint_config_output.CreateEndpointConfigOutput"
):
    """<p>Creates an endpoint configuration that SageMaker hosting services uses to deploy models. In the configuration, you identify one or more models, created using the <code>CreateModel</code> API, to deploy and the resources that you want SageMaker to provision. Then you call the <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html">CreateEndpoint</a> API.</p> <note> <p> Use this API if you want to use SageMaker hosting services to deploy models into production. </p> </note> <p>In the request, you define a <code>ProductionVariant</code>, for each model that you want to deploy. Each <code>ProductionVariant</code> parameter also describes the resources that you want SageMaker to provision. This includes the number and type of ML compute instances to deploy. </p> <p>If you are hosting multiple models, you also assign a <code>VariantWeight</code> to specify how much traffic you want to allocate to each model. For example, suppose that you want to host two models, A and B, and you assign traffic weight 2 for model A and 1 for model B. SageMaker distributes two-thirds of the traffic to Model A, and one-third to model B. </p> <note> <p>When you call <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html">CreateEndpoint</a>, a load call is made to DynamoDB to verify that your endpoint configuration exists. When you read data from a DynamoDB table supporting <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html"> <code>Eventually Consistent Reads</code> </a>, the response might not reflect the results of a recently completed write operation. The response might include some stale data. If the dependent entities are not yet in DynamoDB, this causes a validation error. If you repeat your read request after a short time, the response should return the latest data. So retry logic is recommended to handle these possible issues. We also recommend that customers call <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpointConfig.html">DescribeEndpointConfig</a> before calling <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html">CreateEndpoint</a> to minimize the potential impact of a DynamoDB eventually consistent read.</p> </note>

    Args:
        endpoint_config_name: <p>The name of the endpoint configuration. You specify this name in a <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html">CreateEndpoint</a> request. </p>
        production_variants: <p>An array of <code>ProductionVariant</code> objects, one for each model that you want to host at this endpoint.</p>
        tags: <p>An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in different ways, for example, by purpose, owner, or environment. For more information, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html">Tagging Amazon Web Services Resources</a>.</p>
        kms_key_id: <p>The Amazon Resource Name (ARN) of a Amazon Web Services Key Management Service key that SageMaker uses to encrypt data on the storage volume attached to the ML compute instance that hosts the endpoint.</p> <p>The KmsKeyId can be any of the following formats: </p> <ul> <li> <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code> </p> </li> <li> <p>Key ARN: <code>arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code> </p> </li> <li> <p>Alias name: <code>alias/ExampleAlias</code> </p> </li> <li> <p>Alias name ARN: <code>arn:aws:kms:us-west-2:111122223333:alias/ExampleAlias</code> </p> </li> </ul> <p>The KMS key policy must grant permission to the IAM role that you specify in your <code>CreateEndpoint</code>, <code>UpdateEndpoint</code> requests. For more information, refer to the Amazon Web Services Key Management Service section<a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html"> Using Key Policies in Amazon Web Services KMS </a> </p> <note> <p>Certain Nitro-based instances include local storage, dependent on the instance type. Local storage volumes are encrypted using a hardware module on the instance. If any of the models that you specify in the <code>ProductionVariants</code> parameter use nitro-based instances with local storage, the <code>KmsKeyId</code> parameter does not encrypt instance local storage.</p> <p>For a list of instance types that support local instance storage, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes">Instance Store Volumes</a>.</p> <p>For more information about local instance storage encryption, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssd-instance-store.html">SSD Instance Store Volumes</a>.</p> </note>
        async_inference_config: <p>Specifies configuration for how an endpoint performs asynchronous inference. This is a required field in order for your Endpoint to be invoked using <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_runtime_InvokeEndpointAsync.html">InvokeEndpointAsync</a>.</p>
        explainer_config: <p>A member of <code>CreateEndpointConfig</code> that enables explainers.</p>
        shadow_production_variants: <p>An array of <code>ProductionVariant</code> objects, one for each model that you want to host at this endpoint in shadow mode with production traffic replicated from the model specified on <code>ProductionVariants</code>. If you use this field, you can only specify one variant for <code>ProductionVariants</code> and one variant for <code>ShadowProductionVariants</code>.</p>
        execution_role_arn: <p>The Amazon Resource Name (ARN) of an IAM role that Amazon SageMaker AI can assume to perform actions on your behalf. For more information, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html">SageMaker AI Roles</a>. </p> <note> <p>To be able to pass this role to Amazon SageMaker AI, the caller of this action must have the <code>iam:PassRole</code> permission.</p> </note>
        enable_network_isolation: <p>Sets whether all model containers deployed to the endpoint are isolated. If they are, no inbound or outbound network calls can be made to or from the model containers.</p>
        metrics_config: <p>The configuration parameters for utilization metrics.</p>

    Raises:
        capo_sagemaker.errors.resource_limit_exceeded.ResourceLimitExceeded: <p> You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created. </p>
        capo_sagemaker.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sagemaker.types.create_endpoint_config_input.CreateEndpointConfigInput]",
    ) -> OperationResponse[
        "capo_sagemaker.types.create_endpoint_config_output.CreateEndpointConfigOutput"
    ]:
        import capo_sagemaker._operations.sage_maker.create_endpoint_config

        output, http_response = (
            capo_sagemaker._operations.sage_maker.create_endpoint_config.create_endpoint_config(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateEndpointConfig")
    )
    input_: capo_sagemaker.types.create_endpoint_config_input.CreateEndpointConfigInput = {}
    if endpoint_config_name is not None:
        input_["endpoint_config_name"] = endpoint_config_name
    if production_variants is not None:
        input_["production_variants"] = production_variants
    if data_capture_config is not None:
        input_["data_capture_config"] = data_capture_config
    if tags is not None:
        input_["tags"] = tags
    if kms_key_id is not None:
        input_["kms_key_id"] = kms_key_id
    if async_inference_config is not None:
        input_["async_inference_config"] = async_inference_config
    if explainer_config is not None:
        input_["explainer_config"] = explainer_config
    if shadow_production_variants is not None:
        input_["shadow_production_variants"] = shadow_production_variants
    if execution_role_arn is not None:
        input_["execution_role_arn"] = execution_role_arn
    if vpc_config is not None:
        input_["vpc_config"] = vpc_config
    if enable_network_isolation is not None:
        input_["enable_network_isolation"] = enable_network_isolation
    if metrics_config is not None:
        input_["metrics_config"] = metrics_config

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output