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
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 * * *"
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
-
arn
optional computed - string -
autoscaling_group_name
required - string -
desired_capacity
optional computed - number -
end_time
optional computed - string -
id
optional computed - string -
max_size
optional computed - number -
min_size
optional computed - number -
recurrence
optional computed - string -
scheduled_action_name
required - string -
start_time
optional computed - string
Explanation in Terraform Registry
Provides an AutoScaling Schedule resource.
Tips: Best Practices for The Other AWS Amazon EC2 Auto Scaling Resources
In addition to the aws_launch_configuration, AWS Amazon EC2 Auto Scaling has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
aws_launch_configuration
Check public IPs should be given to Auto Scaling instances
It is better to block public access on the Internet to them. It is better to avoid associating public IP addresses if this is unintentional.
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.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
-
AutoScalingGroupName
required - String -
DesiredCapacity
optional - Integer -
EndTime
optional - String -
MaxSize
optional - Integer -
MinSize
optional - Integer -
Recurrence
optional - String -
StartTime
optional - String -
TimeZone
optional - String
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 theAWS::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.