Reputation: 117
I want to know if it is possible in any way to update this field "Minimum Number of Tasks" (no matter the language, if is available in lambda)
Why ? Because I have problems with the balancer that I have linked to the service.
From the NodeJS SDK, I can change the desired tasks field which is fine, but the tasks created are stopped by the alarms that I have in Cloudwatch.
What I see is that I have to update the two so that they do not stop.
How can edit this field in my service of my cluster on ecs?
Upvotes: 2
Views: 2371
Reputation: 85
Taking the reference from this link, you'll have to do it in 2 steps, using application auto-scaling boto3 client:
register_scalable_target()
with for example MinCapacity=3
and MaxCapacity=100
. This call will return the scalable target ARN.register_scalable_target()
again with MinCapacity=0 and every business day morning again with MinCapacity=3
.See the register_scalable_target() documentation where it explicitly says:
After you have registered a scalable target, you can use this operation to update the minimum and maximum values for its scalable dimension.
Your auto-scaling policy will then set DesiredCapacity within the Min/MaxCapacity boundaries where the MinCapacity will change from 0 to 3 during business hours and back to 0 after hours.
Upvotes: 1
Reputation: 22913
To update a scalable target, specify the parameters that you want to change. Include the parameters that identify the scalable target: resource ID, scalable dimension, and namespace. Any parameters that you don't specify are not changed by this update request.
This golang example shows how to update the minimum number of tasks (minimum capacity) of an ECS service:
import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/applicationautoscaling"
)
sess, _ := session.NewSession()
aas := applicationautoscaling.New(sess)
res, err := aas.RegisterScalableTarget(
&applicationautoscaling.RegisterScalableTargetInput{
MinCapacity: aws.Int64(int64(5)),
ServiceNamespace: aws.String("ecs"),
ResourceId: aws.String("service/cluster_name/service_name"),
ScalableDimension: aws.String("ecs:service:DesiredCount"),
},
)
Upvotes: 0
Reputation: 4677
Check the ApplicationAutoScaling class. I'm not familiar with this particular SDK, but application autoscaling is where min and max tasks are defined in boto3 and in the awscli.
Upvotes: 2