When you create an ECS autoscaling policy, two alarms tag along with it: one for scaling up ("out"), one for scaling down ("in").
The scale-out ones I see created appear to sample CPU utilization (or the metric of interest) every minute, and only trigger automatic scaling when three consecutive data points have breached the threshold.
This means that if I see a traffic spike, three minutes will pass before scale-out happens. (In fact, on average the threshold breach will happen in the middle of a sampling interval, so the delay is three and a half minutes.)
I can adjust the sampling rate and the number of data points required through the AWS console web interface.
However, I would like to manage my infrastructure through Terraform.
How can I use Terraform but no manual clickery to shorten the time between (a) the first breach of the threshold; and (b) the point in time at which I begin the scale-out? (Also: is this a dumb thing to attempt? Am I going about it in an awk-basscards way?)
As far as I can tell, it looks like ice skating uphill: creating autoscaling policies (which I can do through Terraform) automatically creates two alarms and returns handles to them (see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PutScalingPolicy.html) but Terraform doesn't expose those handles (see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appautoscaling_policy#attributes-reference). Is it still possible in Terraform? Does it require heroic efforts?