I want to scale down my services outside of business hours. I use Terraform to maintain my infrastructure. Should I redeploy my infrastructure with a different set of Terraform variables based on if we are inside or outside of business hours from a Lambda function with Terraform apply or should I just change the desired count through the AWS API with the Lambda function and use a lifecycle ignore changes on the desired count in the Terraform configuration? Jenkins is not an option for me.
The autoscaling group will give more control, it will be simpler to manage and will pick the right value for you resulting cheaper.
To simplify, you come up with a metric that represents how much load is currently in the system and then ask AWS to spin up or down instances to maintain that metric at a specific value (eg. 80%)
There’s a number of ways to have ECS automatically scale for you. It’s pretty standard to scale based on CPU usage, but you can use other triggers if that doesn’t work for your use-case.