From 50f817f9f4542907f43c3260660036b09d7146f6 Mon Sep 17 00:00:00 2001 From: Peter Sin Date: Tue, 15 Sep 2026 11:49:14 -0700 Subject: [PATCH] separate out variant_name and model_name --- aws/sagemaker-inference/README.md | 43 +++++++++++++++---- .../sagemaker-endpoint-configuration.tf | 8 ++-- aws/sagemaker-inference/variables.tf | 12 +++++- 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/aws/sagemaker-inference/README.md b/aws/sagemaker-inference/README.md index 327c32a..4b9127b 100644 --- a/aws/sagemaker-inference/README.md +++ b/aws/sagemaker-inference/README.md @@ -20,7 +20,7 @@ This module builds and configures SageMaker inference models and endpoints ```terraform module "basic_usage" { - source = "github.com/FriendsOfTerraform/aws-sagemaker-inference.git?ref=v1.0.0" + source = "github.com/FriendsOfTerraform/aws-sagemaker-inference.git?ref=v1.2.0" # manages multiple models models = { @@ -45,9 +45,12 @@ module "basic_usage" { realtime-endpoint = { provisioned = { production_variants = { - # must refer to models created by this module - demo-model = { - instance_type = "ml.m5.large" + # the keys of the map are variant names + demo-variant = { + instance_type = "ml.m5.large" + + # must refer to models created by this module + model_name = "demo-model" auto_scaling = { policies = { @@ -759,7 +762,7 @@ Specify the number of seconds to wait between scale-out actions. #### production_variants -Configure multiple production variants, one for each model that you want to host at this endpoint. +Configure multiple production variants, one for each model that you want to host at this endpoint. The keys of the map are the variant names. **Since:** 1.0.0 @@ -775,6 +778,18 @@ The EC2 instance type **Since:** 1.0.0 + + + string + model_name + + + + +The name of the model to be hosted on this variant. The model specified must be managed by the same module + +**Since:** 1.2.0 + string @@ -895,7 +910,7 @@ Creates a provisioned endpoint, mutually exclusive to `serverless`. Must specify -Configure multiple production variants, one for each model that you want to host at this endpoint. +Configure multiple production variants, one for each model that you want to host at this endpoint. The keys of the map are the variant names. **Since:** 1.0.0 @@ -931,7 +946,7 @@ Enables data capture, where SageMaker can save prediction request and prediction -Specify shadow variants to receive production traffic replicated from the model specified on `production_variants`. If you use this field, you can only specify one variant for `production_variants` and one variant for `shadow_variants`. +Specify shadow variants to receive production traffic replicated from the model specified on `production_variants`. The keys of the map are the variant names. If you use this field, you can only specify one variant for `production_variants` and one variant for `shadow_variants`. **Since:** 1.0.0 @@ -961,7 +976,7 @@ Configures variant for this endpoint #### shadow_variants -Specify shadow variants to receive production traffic replicated from the model specified on `production_variants`. If you use this field, you can only specify one variant for `production_variants` and one variant for `shadow_variants`. +Specify shadow variants to receive production traffic replicated from the model specified on `production_variants`. The keys of the map are the variant names. If you use this field, you can only specify one variant for `production_variants` and one variant for `shadow_variants`. **Since:** 1.0.0 @@ -977,6 +992,18 @@ The EC2 instance type **Since:** 1.0.0 + + + string + model_name + + + + +The name of the model to be hosted on this variant. The model specified must be managed by the same module + +**Since:** 1.2.0 + number diff --git a/aws/sagemaker-inference/sagemaker-endpoint-configuration.tf b/aws/sagemaker-inference/sagemaker-endpoint-configuration.tf index b76226a..dc83ee1 100644 --- a/aws/sagemaker-inference/sagemaker-endpoint-configuration.tf +++ b/aws/sagemaker-inference/sagemaker-endpoint-configuration.tf @@ -13,8 +13,8 @@ resource "aws_sagemaker_endpoint_configuration" "provisioned_endpoint_configurat instance_type = production_variants.value.instance_type initial_variant_weight = production_variants.value.initial_weight model_data_download_timeout_in_seconds = production_variants.value.model_data_download_timeout != null ? split(" ", production_variants.value.model_data_download_timeout)[0] * local.time_table[trimsuffix(split(" ", production_variants.value.model_data_download_timeout)[1], "s")] : null - model_name = aws_sagemaker_model.models[production_variants.key].name - variant_name = aws_sagemaker_model.models[production_variants.key].name + model_name = aws_sagemaker_model.models[production_variants.value.model_name].name + variant_name = production_variants.key volume_size_in_gb = production_variants.value.volume_size } } @@ -91,8 +91,8 @@ resource "aws_sagemaker_endpoint_configuration" "provisioned_endpoint_configurat instance_type = shadow_production_variants.value.instance_type initial_variant_weight = shadow_production_variants.value.initial_weight model_data_download_timeout_in_seconds = shadow_production_variants.value.model_data_download_timeout != null ? split(" ", shadow_production_variants.value.model_data_download_timeout)[0] * local.time_table[trimsuffix(split(" ", shadow_production_variants.value.model_data_download_timeout)[1], "s")] : null - model_name = aws_sagemaker_model.models[shadow_production_variants.key].name - variant_name = aws_sagemaker_model.models[shadow_production_variants.key].name + model_name = aws_sagemaker_model.models[shadow_production_variants.value.model_name].name + variant_name = shadow_production_variants.key volume_size_in_gb = shadow_production_variants.value.volume_size } } diff --git a/aws/sagemaker-inference/variables.tf b/aws/sagemaker-inference/variables.tf index 4c6ed4f..147d9d7 100644 --- a/aws/sagemaker-inference/variables.tf +++ b/aws/sagemaker-inference/variables.tf @@ -108,7 +108,7 @@ variable "endpoints" { /// /// @since 1.0.0 provisioned = optional(object({ - /// Configure multiple production variants, one for each model that you want to host at this endpoint. + /// Configure multiple production variants, one for each model that you want to host at this endpoint. The keys of the map are the variant names. /// /// @since 1.0.0 production_variants = map(object({ @@ -116,6 +116,10 @@ variable "endpoints" { /// /// @since 1.0.0 instance_type = string + /// The name of the model to be hosted on this variant. The model specified must be managed by the same module + /// + /// @since 1.2.0 + model_name = string /// The timeout value for the inference container to pass health check by SageMaker AI Hosting. /// /// @enum 1 minute|1 hour @@ -281,7 +285,7 @@ variable "endpoints" { }), {}) }), null) - /// Specify shadow variants to receive production traffic replicated from the model specified on `production_variants`. If you use this field, you can only specify one variant for `production_variants` and one variant for `shadow_variants`. + /// Specify shadow variants to receive production traffic replicated from the model specified on `production_variants`. The keys of the map are the variant names. If you use this field, you can only specify one variant for `production_variants` and one variant for `shadow_variants`. /// /// @since 1.0.0 shadow_variants = optional(map(object({ @@ -289,6 +293,10 @@ variable "endpoints" { /// /// @since 1.0.0 instance_type = string + /// The name of the model to be hosted on this variant. The model specified must be managed by the same module + /// + /// @since 1.2.0 + model_name = string /// The timeout value for the inference container to pass health check by SageMaker AI Hosting. Valid values: `"1 minute"` - `"1 hour"` /// /// @since 1.0.0