This Cloud Formation template is designed to increase and decrease the number of ECS Services. The motivation is to reduce the cost of ECS Service by reducing the number of ECS Service during the night. If you stop your Fargate(1 vCPU, 2.00 GB) on half of day (meaning out of working time), you can reduce about 22.18 USD per month due to AWS Pricing Calculator🤩!
This template is effective in these cases
- You are running Fargate in a test or staging environment.
- Your application is not a 24 hour service.
- The traffic is not so high during the night. (But this can be solved by using AWS Auto Scaling)
- EventBridge triggers the Step Functions at a specified time.
- The Step Functions then execute the UpdateService Lambda function, updating the number of ECS services.
- If the previous step is successful, the Step Functions execute the WaitForStable Lambda function to wait for the ECS Service to stabilize.
You can give it a try by under quick-create links.
Parameter | Description | Default |
---|---|---|
ClusterName | The name of the ECS cluster you need to manage. | |
ServiceName | The name of the ECS service for which you want to update the number. | |
ECSRegion | The region of the ECS service. | ap-northeast-1 |
DayCount | The number of ECS service needed during the day. | 1 |
NightCount | The number of ECS service needed during the night. | 0 |
DayStartTime | The time(UTC) to start ECS service during the day. | 8 |
NightStartTime | The time(UTC) to stop ECS service during the night. | 21 |