Managing scheduled scaling for Application Auto Scaling - Application Auto Scaling

Managing scheduled scaling for Application Auto Scaling

The AWS CLI includes several other commands that help you manage your scheduled actions.

Viewing scaling activities for a specified service

To view the scaling activities for all of the scalable targets in a specified service namespace, use the describe-scaling-activities command.

The following example retrieves the scaling activities associated with the dynamodb service namespace.

Linux, macOS, or Unix

aws application-autoscaling describe-scaling-activities --service-namespace dynamodb

Windows

aws application-autoscaling describe-scaling-activities --service-namespace dynamodb

If the command succeeds, you see output similar to the following.

{ "ScalingActivities": [ { "ScalableDimension": "dynamodb:table:WriteCapacityUnits", "Description": "Setting write capacity units to 10.", "ResourceId": "table/my-table", "ActivityId": "4d1308c0-bbcf-4514-a673-b0220ae38547", "StartTime": 1561574415.086, "ServiceNamespace": "dynamodb", "EndTime": 1561574449.51, "Cause": "maximum capacity was set to 10", "StatusMessage": "Successfully set write capacity units to 10. Change successfully fulfilled by dynamodb.", "StatusCode": "Successful" }, { "ScalableDimension": "dynamodb:table:WriteCapacityUnits", "Description": "Setting min capacity to 5 and max capacity to 10", "ResourceId": "table/my-table", "ActivityId": "f2b7847b-721d-4e01-8ef0-0c8d3bacc1c7", "StartTime": 1561574414.644, "ServiceNamespace": "dynamodb", "Cause": "scheduled action name my-second-scheduled-action was triggered", "StatusMessage": "Successfully set min capacity to 5 and max capacity to 10", "StatusCode": "Successful" }, { "ScalableDimension": "dynamodb:table:WriteCapacityUnits", "Description": "Setting write capacity units to 15.", "ResourceId": "table/my-table", "ActivityId": "d8ea4de6-9eaa-499f-b466-2cc5e681ba8b", "StartTime": 1561574108.904, "ServiceNamespace": "dynamodb", "EndTime": 1561574140.255, "Cause": "minimum capacity was set to 15", "StatusMessage": "Successfully set write capacity units to 15. Change successfully fulfilled by dynamodb.", "StatusCode": "Successful" }, { "ScalableDimension": "dynamodb:table:WriteCapacityUnits", "Description": "Setting min capacity to 15 and max capacity to 20", "ResourceId": "table/my-table", "ActivityId": "3250fd06-6940-4e8e-bb1f-d494db7554d2", "StartTime": 1561574108.512, "ServiceNamespace": "dynamodb", "Cause": "scheduled action name my-first-scheduled-action was triggered", "StatusMessage": "Successfully set min capacity to 15 and max capacity to 20", "StatusCode": "Successful" } ] }

To change this command so that it retrieves the scaling activities for only one of your scalable targets, add the --resource-id option.

Describing all scheduled actions for a specified service

To describe the scheduled actions for all of the scalable targets in a specified service namespace, use the describe-scheduled-actions command.

The following example retrieves the scheduled actions associated with the ec2 service namespace.

Linux, macOS, or Unix

aws application-autoscaling describe-scheduled-actions --service-namespace ec2

Windows

aws application-autoscaling describe-scheduled-actions --service-namespace ec2

If successful, this command returns output similar to the following.

{ "ScheduledActions": [ { "ScheduledActionName": "my-one-time-action", "ScheduledActionARN": "arn:aws:autoscaling:us-west-2:123456789012:scheduledAction:493a6261-fbb9-432d-855d-3c302c14bdb9:resource/ec2/spot-fleet-request/sfr-107dc873-0802-4402-a901-37294EXAMPLE:scheduledActionName/my-one-time-action", "ServiceNamespace": "ec2", "Schedule": "at(2021-01-31T17:00:00)", "Timezone": "America/New_York", "ResourceId": "spot-fleet-request/sfr-107dc873-0802-4402-a901-37294EXAMPLE", "ScalableDimension": "ec2:spot-fleet-request:TargetCapacity", "ScalableTargetAction": { "MaxCapacity": 1 }, "CreationTime": 1607454792.331 }, { "ScheduledActionName": "my-recurring-action", "ScheduledActionARN": "arn:aws:autoscaling:us-west-2:123456789012:scheduledAction:493a6261-fbb9-432d-855d-3c302c14bdb9:resource/ec2/spot-fleet-request/sfr-107dc873-0802-4402-a901-37294EXAMPLE:scheduledActionName/my-recurring-action", "ServiceNamespace": "ec2", "Schedule": "rate(5 minutes)", "ResourceId": "spot-fleet-request/sfr-107dc873-0802-4402-a901-37294EXAMPLE", "ScalableDimension": "ec2:spot-fleet-request:TargetCapacity", "StartTime": 1604059200.0, "EndTime": 1612130400.0, "ScalableTargetAction": { "MinCapacity": 3, "MaxCapacity": 10 }, "CreationTime": 1607454949.719 }, { "ScheduledActionName": "my-one-time-action", "ScheduledActionARN": "arn:aws:autoscaling:us-west-2:123456789012:scheduledAction:4bce34c7-bb81-4ecf-b776-5c726efb1567:resource/ec2/spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE:scheduledActionName/my-one-time-action", "ServiceNamespace": "ec2", "Schedule": "at(2020-12-08T9:36:00)", "Timezone": "America/New_York", "ResourceId": "spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE", "ScalableDimension": "ec2:spot-fleet-request:TargetCapacity", "ScalableTargetAction": { "MinCapacity": 1, "MaxCapacity": 3 }, "CreationTime": 1607456031.391 } ] }

Describing one or more scheduled actions for a scalable target

To retrieve information about the scheduled actions for a specified scalable target, add the --resource-id option when describing scheduled actions using the describe-scheduled-actions command.

If you include the --scheduled-action-names option and specify the name of a scheduled action as its value, the command returns only the scheduled action whose name is a match, as shown in the following example.

Linux, macOS, or Unix

aws application-autoscaling describe-scheduled-actions --service-namespace ec2 \ --resource-id spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE \ --scheduled-action-names my-one-time-action

Windows

aws application-autoscaling describe-scheduled-actions --service-namespace ec2 --resource-id spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE --scheduled-action-names my-one-time-action

The following is example output.

{ "ScheduledActions": [ { "ScheduledActionName": "my-one-time-action", "ScheduledActionARN": "arn:aws:autoscaling:us-west-2:123456789012:scheduledAction:4bce34c7-bb81-4ecf-b776-5c726efb1567:resource/ec2/spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE:scheduledActionName/my-one-time-action", "ServiceNamespace": "ec2", "Schedule": "at(2020-12-08T9:36:00)", "Timezone": "America/New_York", "ResourceId": "spot-fleet-request/sfr-40edeb7b-9ae7-44be-bef2-5c4c8EXAMPLE", "ScalableDimension": "ec2:spot-fleet-request:TargetCapacity", "ScalableTargetAction": { "MinCapacity": 1, "MaxCapacity": 3 }, "CreationTime": 1607456031.391 } ] }

If more than one value is provided for the --scheduled-action-names option, all scheduled actions whose names are a match are included in the output.

Turning off scheduled scaling for a scalable target

You can temporarily turn off scheduled scaling without deleting your scheduled actions. For more information, see Suspending and resuming scaling for Application Auto Scaling.

Suspend scheduled scaling on a scalable target by using the register-scalable-target command with the --suspended-state option, and specifying true as the value of the ScheduledScalingSuspended attribute, as shown in the following example.

Linux, macOS, or Unix

aws application-autoscaling register-scalable-target --service-namespace rds \ --scalable-dimension rds:cluster:ReadReplicaCount --resource-id cluster:my-db-cluster \ --suspended-state '{"ScheduledScalingSuspended": true}'

Windows

aws application-autoscaling register-scalable-target --service-namespace rds --scalable-dimension rds:cluster:ReadReplicaCount --resource-id cluster:my-db-cluster --suspended-state "{\"ScheduledScalingSuspended\": true}"

If successful, this command returns to the prompt.

To resume scheduled scaling, run this command again, specifying false as the value of the ScheduledScalingSuspended attribute.

Deleting a scheduled action

When you are finished with a scheduled action, you can delete it using the delete-scheduled-action command.

Linux, macOS, or Unix

aws application-autoscaling delete-scheduled-action --service-namespace ec2 \ --scalable-dimension ec2:spot-fleet-request:TargetCapacity \ --resource-id spot-fleet-request/sfr-73fbd2ce-aa30-494c-8788-37294EXAMPLE \ --scheduled-action-name my-recurring-action

Windows

aws application-autoscaling delete-scheduled-action --service-namespace ec2 --scalable-dimension ec2:spot-fleet-request:TargetCapacity --resource-id spot-fleet-request/sfr-73fbd2ce-aa30-494c-8788-37294EXAMPLE --scheduled-action-name my-recurring-action

If successful, this command returns to the prompt.