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
  }
}


gefragt vor 2 Jahren603 Aufrufe
1 Antwort
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
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen