I created a Capacity Provider.
Then, I deployed a Service with that Capacity Provider and with binpack (CPU) strategy.
Service:
Type: AWS::ECS::Service
Properties:
ServiceName: my-service
TaskDefinition: my-td
Cluster: my-cluster
CapacityProviderStrategy:
- CapacityProvider: my-capacity-provider
Weight: 1
PlacementStrategies:
- Type: binpack
Field: cpu
DesiredCount: 1
This also creates the alarms in CW for high and low CPU usage.
When I add 15 tasks, after a while, the high alarm goes on and new EC2 instances are added.
Then, if I update the number of tasks to 6... Nothing happens. The low usage alarm is never triggered and the EC2 instances are not removed.
However, the service deregisters the extra tasks but the required 6 and enters to steady state.
Does anyone have this issue? What can I do?
I know I could go to ECS Cluster, then in the ECS instances tab select the extra EC2 instances and drain them. However, this manual action would kill the purpose o using CloudFormation.