how to add autoscaling policy to an sagemaker endpoint via terraform?

0

based on the documentation here, https://github.com/aws/amazon-sagemaker-examples/blob/main/async-inference/Async-Inference-Walkthrough.ipynb, an autoscaling policy could be added to an sagemaker async endpoint . I want to set this via terraform and have this so far (sample below) , but i'm not how to set Dimensions attribute in TargetTrackingScalingPolicyConfiguration in terraform?

  TargetTrackingScalingPolicyConfiguration={
        "TargetValue": 5.0, SageMakerVariantInvocationsPerInstance
        "CustomizedMetricSpecification": {
            "MetricName": "ApproximateBacklogSizePerInstance",
            "Namespace": "AWS/SageMaker",
            "Dimensions": [{"Name": "EndpointName", "Value": endpoint_name}],
            "Statistic": "Average",
        },
resource "aws_appautoscaling_target" "sagemaker_target" {
  max_capacity       =  3
  min_capacity       = 1
  resource_id        = "myendpoint"
  scalable_dimension = "sagemaker:variant:DesiredInstanceCount"
  service_namespace  = "sagemaker"
}

resource "aws_appautoscaling_policy" "sagemaker_policy" {
  name               = "somepolicy"
  policy_type        = "TargetTrackingScaling"
  resource_id        = aws_appautoscaling_target.sagemaker_target.resource_id
  scalable_dimension = aws_appautoscaling_target.sagemaker_target.scalable_dimension
  service_namespace  = aws_appautoscaling_target.sagemaker_target.service_namespace

  target_tracking_scaling_policy_configuration {
    customized_metric_specification{
      metric_name = "ApproximateBacklogSizePerInstance"
      namespace =  "AWS/SageMaker"
      Dimensions = ....?????
      statistic =  "Average"
    }
    target_value       = 3
    scale_in_cooldown  =300
    scale_out_cooldown = 600
  }
}


asked 2 years ago587 views
1 Answer
0

Hi,

This Dimensions refer to the CloudWatch dimensions of metric ApproximateBacklogSizePerInstance. It's the same dimension when you first define the metric as described in doc here

AWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions