AWS Instance Scheduler
AWS Instance Scheduler contributes to the reduction of operational costs by turning off resources that are not in use and turning on resources when additional capacity is required. Example: A corporation can utilize AWS Instance Scheduler in a production setting to automatically halt instances outside of business hours on a daily basis, saving time and money. If you leave all of your instances running at 100% utilization, this approach may result in a reduction in instance utilization, which will result in a reduction in overall cost based on the schedules that have been set up for the instances.
The architecture depicted in the diagram below is one that can be automatically deployed using the solution’s implementation guide and associated AWS CloudFormation template, as shown:
Image Sourced from Amazon Web Services
Architecture of the Amazon Web Services Instance Scheduler
- The AWS CloudFormation template creates an Amazon CloudWatch event that occurs at a customer-defined interval. This event triggers the AWS Instance Scheduler AWS Lambda function, which is then executed. AWS Regions and accounts, as well as a custom tag, are defined throughout the configuration process. This tag is used by AWS Instance Scheduler to associate schedules with suitable Amazon EC2 and Amazon RDS instances.
- Amazon DynamoDB stores these values, and the Lambda function retrieves them each time it is called. After that, you can apply the custom tag to the instances that are appropriate.
- When configuring the Instance Scheduler for the first time, you provide a tag key that will be used to identify the applicable Amazon EC2 and Amazon RDS instances. As a result of creating a schedule, the name you specify is utilized as the tag value, which uniquely identifies the schedule you wish to apply to the tagged resource that you created. Using the solution’s default tag name (tag key) Schedule, for example, a user may construct a schedule named uk-office-hours using the solution’s default tag name (tag key) Schedule. In order to identify an instance that will utilize the uk-office-hours schedule, the user must include the Schedule tag key with the value uk-office-hours in the instance’s tag definition.
Download list of all AWS Services PDF
Scheduling instances across multiple accounts
Among the features of this solution is a template for creating the AWS Identity and Access Management (IAM) roles that are required for starting and stopping instances in secondary accounts.
Automated tagging of blanks
AWS Instance Scheduler has the capability of automatically adding tags to any instances that it starts or terminates. The solution also contains macros that allow you to insert variable information in the tags.
Scheduler CLI allows you to create schedules or periods of time.
Several commands for configuring schedules and periods are available through the command line interface (CLI) of this solution. Clients can use the CLI to estimate cost reductions for a specific time frame.
Schedules or periods can be configured through the SSM maintenance window.
For EC2 instances, AWS Instance Scheduler can utilize SSM maintenance windows that have been created in the same Region as the instances, and it can start and stop the instances during the duration of the maintenance window.
Table for configuring the scheduler
When the AWS Instance Scheduler is installed, it produces an Amazon DynamoDB database that holds the configuration parameters for the entire system. After the solution has been deployed, you can make changes to these global configuration parameters by updating the AWS CloudFormation stack. Do not make any changes to the values stored in the DynamoDB table. If you make changes to the values recorded in the DynamoDB table, you will cause a conflict between the stored parameters in the stack and the values stored in the database.
Global configuration items have a type attribute with the value config in the configuration database, which indicates that they are configuration items. Schedules and periods both contain type characteristics with values corresponding to the schedule and period types, respectively, in their definitions. It is possible to create, update, and remove schedules and periods from the configuration database by using the DynamoDB console or the command line interface provided by the solution.
Need help on AWS?
AWS Partners, such as AllCode, are trusted and recommended by Amazon Web Services to help you deliver with confidence. AllCode employs the same mission-critical best practices and services that power Amazon’s monstrous ecommerce platform.
Set up Amazon Elastic Compute Cloud (Amazon EC2) and Amazon Relational Database Service (Amazon RDS) schedules. Each schedule must have its own name, which is used as the tag value for the tagged resource.
A period defining when the instance will run is required for every schedule. In a schedule, there might be multiple periods. Each time the Instance Scheduler finds that at least one of the period rules is true, it takes the appropriate start action.
The schedule also allows you to pick a time zone. Default time zone will be used if no time zone is specified when the solution is launched.
This allows you to put stopped Amazon EC2 instances into hibernation. When the hibernate field is set to true, your EC2 instances will have an AMI. Learn how to hibernate your On-Demand or Reserved Linux Instance in the AEC User Guide for Linux Instances. Hibernation stores RAM contents to your Amazon Elastic Block Store root disc. When the solution ends an instance, this field is set to true.
If you enable hibernation in the solution but your instances aren’t enabled or don’t satisfy the conditions, the solution reports a warning and stops them without hibernation. For further details, see Hibernate your On-Demand or Reserved Linux Instance in the AEC Linux User Guide.
Schedules have an enforced field that prevents instances from being manually started or halted during a running period. If this field is set to true and a user manually starts an instance outside of a running period, the solution will stop it. Instances that were manually stopped during a running period will be restarted if this field is set to true.
Keep running field
It stops the solution from ending an instance if it was started manually prior to the period starting. An instance running from 9 am to 5 pm, for example, cannot be manually started before 9 am.
The SSM window of maintenance
The ssm-maintenance-window field can be used to add an AWS Systems Manager maintenance window to a schedule. Your Amazon EC2 instances will be scheduled to run before and after a maintenance window that exists in the same AWS account and region as your deployed stack. If no other running period specifies that an instance should run, and if a maintenance event has been completed, the solution will start and stop your Amazon EC2 instances. The solution determines how long before the maintenance window to start your instance using the AWS Lambda frequency that you provided during initial configuration of the solution. The solution will start the instance 10 minutes before the maintenance window if the Frequency AWS CloudFormation parameter is set to 10 minutes or less. After setting the frequency to more than 10 minutes, the scheduler will start the instance every 10 minutes. Schedulers launch instances 30 minutes prior to maintenance windows if you set their frequency to 30 minutes. It is recommended that the CloudFormation option Enable SSM Maintenance windows be set to Yes in order to begin loading SSM maintenance windows into a DynamoDB database that will be used when the AWS Lambda function starts.
The status field can be overridden.
To temporarily override start and stop operations, schedules have an override status field that can be used. This means that if you set this field to “running,” the solution will start but not stop. The instance will continue to run unless manually terminated. Stopping the solution, however, does not actually halt the applicable instance. Once the instance is started, it cannot be stopped or restarted.
The solution will terminate the instance if the override status field is set to running but the enforced field is used to prevent an instance from being manually started outside of the running period. It will restart the instance if override status is set to stopped, but enforced is used to prevent the instance from being manually stopped while it is still operating.
Schedules only allow you to provide an optional instance type for each period in a schedule for Amazon EC2 instances. The solution will start an Amazon EC2 instance with the appropriate instance type if you give an instance type in the period.
[email protected] syntax is used to indicate an instance type. [email protected], for instance. Amazon RDS instances will not be scheduled if you choose an instance type that is different from the one that is used to schedule Amazon EC2 instances during that time period.
If the instance type of a running instance differs from the instance type specified for the period, the solution will stop the running instance and restart the instance with the specified instance type, if the specified instance type is compatible with the instance configuration of the running instance.
AWS Service Business Continuity Plan
Thousands of businesses are lose an unprecedented amount of money every quarter - don’t let yours! Protect your AWS services with this FREE AWS Business Continuity Plan. Learn More
Aspects of Design
A largely automated solution is the default for users (i.e., configure start-only or stop-only actions). When a team wants to be able to stop instances at different times (manually) yet must start them at the same time each morning, this is an example of the need for flexibility.
The Amazon Elastic Compute Cloud (EC2).
An Amazon Elastic Compute Cloud (Amazon EC2) instance shutdown action of Stop is assumed in this approach, rather than Terminate. You should be aware that Amazon EC2 instances that have been terminated cannot be restarted.
However, you can override this behaviour by configuring Amazon EC2 instances to halt rather than terminate when shut down. The AWS Instance Scheduler will terminate instances that don’t have a Stop shutdown behaviour set in the instance scheduler settings.
Amazon Real-time Distribution Service (RDS)
Amazon RDS instances can be automatically stopped, but not deleted, via this method. It is designed for this purpose only. Prior to shutting down the RDS instances, you can use the Make RDS Instance Snapshot AWS CloudFormation template parameter to create snapshots of the RDS infrastructure. There are no limits on how long the snapshots are maintained, but they are deleted when the instance is shut down. Amazon Aurora clusters, on the other hand, do not support snapshots.
The solution reports the problem in Amazon CloudWatch Logs and sends an Amazon Simple Notification Service (Amazon SNS) notification to the error SNS topic if the Instance Scheduler AWS Lambda function does not process all scheduled instances before its next execution. In order to ensure that all instances are processed before the next invocation, you may either adjust the default interval at which the Lambda function runs or make several deployments of the solution with different tag names.
When thinking about programming languages, frameworks, and SDKs for mobile web app development, you should consider the front-end (UI) development environment as well as the back-end (server-side) development environment.
An AWS Advanced Technology Partner, Tigera delivers Calico and Calico Enterprise for security and networking on EKS, both of which are AWS Containers Competency certified.
Centro Community Partners (Centro) is a nonprofit organization that provides programs and resources to help underserved entrepreneurs start, develop and grow their small businesses. Centro also offers technology and curriculum to other organizations and trainers through their Entrepreneurship Suite.
Blockchain technology has the potential to be a windfall for musicians, filmmakers, and video game developers. With the advent of new technology, the way we consume entertainment is changing. Vezt assists artists in distributing their tracks on digital channels and in promoting their work.