0

Like below is the example of target tracking ASG policy in TF docs :

resource "aws_autoscaling_policy" "example" {
  # ... other configuration ...

  target_tracking_configuration {
    predefined_metric_specification {
      predefined_metric_type = "ASGAverageCPUUtilization"
    }

    target_value = 40.0
  }

  target_tracking_configuration {
    customized_metric_specification {
      metric_dimension {
        name  = "fuga"
        value = "fuga"
      }

      metric_name = "hoge"
      namespace   = "hoge"
      statistic   = "Average"
    }

    target_value = 40.0
  }
}

I want to create a step scaling policy which also has definition of custom metric like in this block and i am using the below code but getting error saying THIS BLOCK DOES NOT EXIST.


resource "aws_autoscaling_policy" "contentworker_inbound_step_scaling_policy" {
  name                      = "${var.host_group}-${var.stack}-step-scaling-policy"
  policy_type               = "StepScaling"
  autoscaling_group_name    = aws_autoscaling_group.contentworker_inbound_asg.name
  estimated_instance_warmup = 300

  step_configuration {
    customized_metric_specification  {
      metric_dimension {
        name  = "test"
        value = “Size”
      }
      metric_name = "anything"
      namespace   = "test"
      statistic   = "Average"
      unit        = "None"
    }
    step_adjustment {
    adjustment_type              = "PercentChangeInCapacity"
    scaling_adjustment           = 10
    metric_interval_lower_bound = 10
    metric_interval_upper_bound = 25
    }

  }
}

I have the custom metric working fine with the target tracking policy, but not with the step scaling.

Any suggestions how can I setup a step scaling policy for my custom metric

  • 1
    Have you read [the documentation for `aws_autoscaling_policy`](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_policy)? The structure for step scaling policies is very different and instead you need to use `step_adjustment` blocks and they are linked to a Cloudwatch metrics alarm which triggers when to adjust the ASG size rather than directly specifying the metric in the configuration. There's more detail about the non target tracking policies in https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html – ydaetskcoR May 10 '21 at 08:15

0 Answers0