Skip to content

Commit

Permalink
Merge pull request #38085 from DrFaust92/ProductionVariantInferenceAm…
Browse files Browse the repository at this point in the history
…iVersion

r/sagemaker_endpoint_configuration - add support for `inference_ami_version`
  • Loading branch information
ewbankkit committed Jun 24, 2024
2 parents 4ff5898 + 9aa8c6b commit 00c0083
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/38085.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_sagemaker_endpoint_configuration: Add `production_variants.inference_ami_version` and `shadow_production_variants.inference_ami_version` arguments
```
20 changes: 20 additions & 0 deletions internal/service/sagemaker/endpoint_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,12 @@ func ResourceEndpointConfiguration() *schema.Resource {
Optional: true,
ForceNew: true,
},
"inference_ami_version": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice(sagemaker.ProductionVariantInferenceAmiVersion_Values(), false),
},
"initial_instance_count": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -433,6 +439,12 @@ func ResourceEndpointConfiguration() *schema.Resource {
Optional: true,
ForceNew: true,
},
"inference_ami_version": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice(sagemaker.ProductionVariantInferenceAmiVersion_Values(), false),
},
"initial_instance_count": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -697,6 +709,10 @@ func expandProductionVariants(configured []interface{}) []*sagemaker.ProductionV
l.EnableSSMAccess = aws.Bool(v)
}

if v, ok := data["inference_ami_version"].(string); ok && v != "" {
l.InferenceAmiVersion = aws.String(v)
}

containers = append(containers, l)
}

Expand Down Expand Up @@ -750,6 +766,10 @@ func flattenProductionVariants(list []*sagemaker.ProductionVariant) []map[string
l["enable_ssm_access"] = aws.BoolValue(i.EnableSSMAccess)
}

if i.InferenceAmiVersion != nil {
l["inference_ami_version"] = aws.StringValue(i.InferenceAmiVersion)
}

result = append(result, l)
}
return result
Expand Down
46 changes: 46 additions & 0 deletions internal/service/sagemaker/endpoint_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,34 @@ func TestAccSageMakerEndpointConfiguration_ProductionVariants_serverless(t *test
})
}

func TestAccSageMakerEndpointConfiguration_ProductionVariants_ami(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_sagemaker_endpoint_configuration.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.SageMakerServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckEndpointConfigurationDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccEndpointConfigurationConfig_ami(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckEndpointConfigurationExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "production_variants.#", acctest.Ct1),
resource.TestCheckResourceAttr(resourceName, "production_variants.0.inference_ami_version", "al2-ami-sagemaker-inference-gpu-2"), //lintignore:AWSAT002
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccSageMakerEndpointConfiguration_ProductionVariants_serverlessProvisionedConcurrency(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
Expand Down Expand Up @@ -1264,6 +1292,24 @@ resource "aws_sagemaker_endpoint_configuration" "test" {
`, rName))
}

func testAccEndpointConfigurationConfig_ami(rName string) string {
//lintignore:AWSAT002
return acctest.ConfigCompose(testAccEndpointConfigurationConfig_base(rName), fmt.Sprintf(`
resource "aws_sagemaker_endpoint_configuration" "test" {
name = %[1]q
production_variants {
variant_name = "variant-1"
model_name = aws_sagemaker_model.test.name
inference_ami_version = "al2-ami-sagemaker-inference-gpu-2"
instance_type = "ml.t2.medium"
initial_instance_count = 2
initial_variant_weight = 1
}
}
`, rName))
}

func testAccEndpointConfigurationConfig_serverlessProvisionedConcurrency(rName string) string {
return acctest.ConfigCompose(testAccEndpointConfigurationConfig_base(rName), fmt.Sprintf(`
resource "aws_sagemaker_endpoint_configuration" "test" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ This resource supports the following arguments:
* `container_startup_health_check_timeout_in_seconds` - (Optional) The timeout value, in seconds, for your inference container to pass health check by SageMaker Hosting. For more information about health check, see [How Your Container Should Respond to Health Check (Ping) Requests](https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-inference-code.html#your-algorithms-inference-algo-ping-requests). Valid values between `60` and `3600`.
* `core_dump_config` - (Optional) Specifies configuration for a core dump from the model container when the process crashes. Fields are documented below.
* `enable_ssm_access` - (Optional) You can use this parameter to turn on native Amazon Web Services Systems Manager (SSM) access for a production variant behind an endpoint. By default, SSM access is disabled for all production variants behind an endpoints.
* `inference_ami_version` - (Optional) Specifies an option from a collection of preconfigured Amazon Machine Image (AMI) images. Each image is configured by Amazon Web Services with a set of software and driver versions. Amazon Web Services optimizes these configurations for different machine learning workloads.
* `initial_instance_count` - (Optional) Initial number of instances used for auto-scaling.
* `instance_type` - (Optional) The type of instance to start.
* `initial_variant_weight` - (Optional) Determines initial traffic distribution among all of the models that you specify in the endpoint configuration. If unspecified, it defaults to `1.0`.
Expand Down

0 comments on commit 00c0083

Please sign in to comment.