AWS Application Auto Scaling Scheduled Action

This page shows how to write Terraform and CloudFormation for Application Auto Scaling Scheduled Action and write them securely.

aws_appautoscaling_scheduled_action (Terraform)

The Scheduled Action in Application Auto Scaling can be configured in Terraform with the resource name aws_appautoscaling_scheduled_action. The following sections describe 2 examples of how to use the resource and its parameters.

Example Usage from GitHub

aws_autoscale_scheduled_action.tf#L1
resource "aws_appautoscaling_scheduled_action" "autoscaling_week_schedule" {
  name               = element(split(";", var.FleetScheduleName),0)
  service_namespace  = aws_appautoscaling_target.ScalableTarget.service_namespace
  resource_id        = aws_appautoscaling_target.ScalableTarget.resource_id
  scalable_dimension = aws_appautoscaling_target.ScalableTarget.scalable_dimension
  schedule           = element(split(";", var.FleetSchedule),0)
ecs_autoscale_schedule.tf#L2
resource "aws_appautoscaling_scheduled_action" "ADOBuilderWeekdayScaleUp" {
  count              = var.enable_scaling ? 1 : 0
  name               = "ADOBuilderScaleUp"
  service_namespace  = aws_appautoscaling_target.AzureDevOpsBuilderServiceAutoScalingTarget[0].service_namespace
  resource_id        = aws_appautoscaling_target.AzureDevOpsBuilderServiceAutoScalingTarget[0].resource_id
  scalable_dimension = aws_appautoscaling_target.AzureDevOpsBuilderServiceAutoScalingTarget[0].scalable_dimension

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Provides an Application AutoScaling ScheduledAction resource.

AWS::ApplicationAutoScaling::ScalableTarget ScheduledAction (CloudFormation)

The ScalableTarget ScheduledAction in ApplicationAutoScaling can be configured in CloudFormation with the resource name AWS::ApplicationAutoScaling::ScalableTarget ScheduledAction. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.

Parameters

EndTime The date and time that the action is scheduled to end, in UTC.
Required: No
Type: Timestamp
Update requires: No interruption

ScalableTargetAction The new minimum and maximum capacity. You can set both values or just one. At the scheduled time, if the current capacity is below the minimum capacity, Application Auto Scaling scales out to the minimum capacity. If the current capacity is above the maximum capacity, Application Auto Scaling scales in to the maximum capacity.
Required: No
Type: ScalableTargetAction
Update requires: No interruption

Schedule The schedule for this action. The following formats are supported:

  • At expressions - "at(yyyy-mm-ddThh:mm:ss)"
  • Rate expressions - "rate(value unit)"
  • Cron expressions - "cron(fields)" At expressions are useful for one-time schedules. Cron expressions are useful for scheduled actions that run periodically at a specified date and time, and rate expressions are useful for scheduled actions that run at a regular interval.
    At and cron expressions use Universal Coordinated Time (UTC) by default.
    The cron format consists of six fields separated by white spaces: [Minutes] [Hours] [Dayof_Month] [Month] [Day_of_Week] [Year].
    For rate expressions, _value
    is a positive integer and unit is minute | minutes | hour | hours | day | days.
    Required: Yes
    Type: String
    Minimum: 1
    Maximum: 1600
    Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*
    Update requires: No interruption

ScheduledActionName The name of the scheduled action. This name must be unique among all other scheduled actions on the specified scalable target.
Required: Yes
Type: String
Minimum: 1
Maximum: 256
Pattern: (?!((^[ ]+.*)|(.*([\u0000-\u001f]|[\u007f-\u009f]|[:/|])+.*)|(.*[ ]+$))).+
Update requires: No interruption

StartTime The date and time that the action is scheduled to begin, in UTC.
Required: No
Type: Timestamp
Update requires: No interruption

Timezone The time zone used when referring to the date and time of a scheduled action, when the scheduled action uses an at or cron expression.
Required: No
Type: String
Minimum: 1
Maximum: 1600
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*
Update requires: No interruption

Explanation in CloudFormation Registry

ScheduledAction is a property of the AWS::ApplicationAutoScaling::ScalableTarget resource that specifies a scheduled action for a scalable target. For more information, see PutScheduledAction in the Application Auto Scaling API Reference. For more information about scheduled scaling, including the format for cron expressions, see Scheduled scaling in the Application Auto Scaling User Guide.

Frequently asked questions

What is AWS Application Auto Scaling Scheduled Action?

AWS Application Auto Scaling Scheduled Action is a resource for Application Auto Scaling of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Application Auto Scaling Scheduled Action?

For Terraform, the liberops/Terraform-AWS-Appstream and KyMidd/Terraform_ADO_ECR_Multi-Account_Access source code examples are useful. See the Terraform Example section for further details.