AWS Amazon EC2 Auto Scaling Schedule

This page shows how to write Terraform and CloudFormation for Amazon EC2 Auto Scaling Schedule and write them securely.

aws_autoscaling_schedule (Terraform)

The Schedule in Amazon EC2 Auto Scaling can be configured in Terraform with the resource name aws_autoscaling_schedule. The following sections describe 2 examples of how to use the resource and its parameters.

Example Usage from GitHub

github-iconmariakourtesi/terraform-playground
resource "aws_autoscaling_schedule" "scale_out_during_business_hours" {
    sceduled_action_name = "scale-out-during-business-hours"
    min_size = 2
    max_size = 10
    desired_capacity = 10
    recurrence = "0 9 * * *"
github-iconumeshit/awsautomationrepo
resource "aws_autoscaling_schedule" "scaleup_cron" {
  scheduled_action_name  = "start_cron_example"
  min_size               = 2
  max_size               = 4
  desired_capacity       = 4
  start_time             = var.scaleup_start_time

Parameters

Explanation in Terraform Registry

Provides an AutoScaling Schedule resource.

AWS::AutoScaling::ScheduledAction (CloudFormation)

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

Parameters

Explanation in CloudFormation Registry

The AWS::AutoScaling::ScheduledAction resource specifies an Amazon EC2 Auto Scaling scheduled action so that the Auto Scaling group can change the number of instances available for your application in response to predictable load changes. When you update a stack with an Auto Scaling group and scheduled action, CloudFormation always sets the min size, max size, and desired capacity properties of your group to the values that are defined in the AWS::AutoScaling::AutoScalingGroup section of your template. However, you might not want CloudFormation to do that when you have a scheduled action in effect. You can use an UpdatePolicy attribute to prevent CloudFormation from changing the min size, max size, or desired capacity property values during a stack update unless you modified the individual values in your template. If you have rolling updates enabled, before you can update the Auto Scaling group, you must suspend scheduled actions by specifying an UpdatePolicy attribute for the Auto Scaling group. You can find a sample update policy for rolling updates in Auto scaling template snippets.

For more information, see Scheduled scaling and Suspending and resuming scaling processes in the Amazon EC2 Auto Scaling User Guide.

Frequently asked questions

What is AWS Amazon EC2 Auto Scaling Schedule?

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

Where can I find the example code for the AWS Amazon EC2 Auto Scaling Schedule?

For Terraform, the mariakourtesi/terraform-playground and umeshit/awsautomationrepo source code examples are useful. See the Terraform Example section for further details.