I try to use a metric expression for my autoscaling group almost as in the example at Terraform Registry.
but I’ve got the following policy in the AWS console. which is looking not so good.
and I can’t do the same policy by the UI.
and also autoscaling doesn’t work. even when the metrics have the following values
is this option still supported? can you please help me to figure this out?
forgot to provide source code:
resource "aws_autoscaling_policy" "calls" {
autoscaling_group_name = aws_autoscaling_group.asterisk.name
name = "calls"
policy_type = "TargetTrackingScaling"
target_tracking_configuration {
target_value = 10
customized_metric_specification {
metrics {
label = "Total calls number"
id = "totalcount"
metric_stat {
metric {
namespace = "my_namespace"
metric_name = "totalcount"
dimensions {
name = "Environment"
value = local.tags["Environment"]
}
}
stat = "Average"
}
return_data = false
}
metrics {
label = "Get the group size"
id = "number"
metric_stat {
metric {
namespace = "AWS/AutoScaling"
metric_name = "GroupInServiceInstances"
dimensions {
name = "AutoScalingGroupName"
value = aws_autoscaling_group.asterisk.name
}
}
stat = "Average"
}
return_data = false
}
metrics {
label = "Calculate calls per instance"
id = "e1"
expression = "totalcount / number"
return_data = true
}
}
}
}