Forked from toricls/Time-based-auto-scaling-on-fargate.md
Created
February 2, 2020 21:16
-
-
Save bugre/21371773224e71d9255a008fcdbf0cd5 to your computer and use it in GitHub Desktop.
Revisions
-
toricls created this gist
Aug 5, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,70 @@ ### Set parameters ```shell $ export ECS_CLUSTER_NAME={YOUR_ECS_CLUSTER_NAME} $ export ECS_SERVICE_NAME={YOUR_ECS_SERVICE_NAME} ``` ### RegisterScalableTarget ```shell $ aws application-autoscaling register-scalable-target --service-namespace ecs \ --scalable-dimension ecs:service:DesiredCount \ --resource-id service/${ECS_CLUSTER_NAME}/${ECS_SERVICE_NAME} \ --min-capacity 1 \ --max-capacity 3 ``` ### PutScheduledAction ```shell $ export SCALE_OUT_ACTION_NAME=fargate-time-based-scale-out # configure scaling out $ aws application-autoscaling put-scheduled-action --service-namespace ecs \ --scalable-dimension ecs:service:DesiredCount \ --resource-id service/${ECS_CLUSTER_NAME}/${ECS_SERVICE_NAME} \ --scheduled-action-name ${SCALE_OUT_ACTION_NAME} \ --schedule "cron(50 23 * * ? *)" \ # every day at 8:50am JST --scalable-target-action MinCapacity=3,MaxCapacity=10 ``` ```shell $ export SCALE_IN_ACTION_NAME=fargate-time-based-scale-in # configure scaling in $ aws application-autoscaling put-scheduled-action --service-namespace ecs \ --scalable-dimension ecs:service:DesiredCount \ --resource-id service/${ECS_CLUSTER_NAME}/${ECS_SERVICE_NAME} \ --scheduled-action-name ${SCALE_IN_ACTION_NAME} \ --schedule "cron(10 9 * * ? *)" \ # every day at 6:10pm JST --scalable-target-action MinCapacity=1,MaxCapacity=1 ``` ### DeleteScheduledAction ```shell $ aws application-autoscaling delete-scheduled-action --service-namespace ecs \ --scheduled-action-name ${SCALE_OUT_ACTION_NAME} \ --resource-id service/${ECS_CLUSTER_NAME}/${ECS_SERVICE_NAME} \ --scalable-dimension ecs:service:DesiredCount ``` ```shell $ aws application-autoscaling delete-scheduled-action --service-namespace ecs \ --scheduled-action-name ${SCALE_IN_ACTION_NAME} \ --resource-id service/${ECS_CLUSTER_NAME}/${ECS_SERVICE_NAME} \ --scalable-dimension ecs:service:DesiredCount ``` ### DescribeScheduledActions ```shell $ aws application-autoscaling describe-scheduled-actions --service-namespace ecs \ --scheduled-action-names ${SCALE_IN_ACTION_NAME} ${SCALE_OUT_ACTION_NAME} ``` ### See also https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-scheduled-scaling.html