For the benefit of users visiting this answer in future, here is a more elaborate explanation:
EC2 allows you to set/change the capacity of your auto scaling group manually, based on schedule or based on demand, as outlined in the docs .
However the term manual scaling can be somewhat misleading, because like almost every aspect of AWS, everything that you can do manually can be scripted either through the CLI or through SDKs.
I case of EC2 auto scaling group the capacity is configurable and it can be changed dynamically in the runtime - the change in capacity will cause instances to be added or removed automatically.
So in this case a solution would be to detect lifecycle events specific to your application in your application code, and in response to those events use the relevant AWS SDK to change the capacity of your autoscaling group.
In ruby this can be done as follows (Examples taken from AWS API documentation):
autoscaling = Aws::AutoScaling::Client.new(
region: region_name,
credentials: credentials
)
resp = autoscaling.set_desired_capacity(
# required
auto_scaling_group_name: "ResourceName",
# required
desired_capacity: 1,
honor_cooldown: true,
)