Automate EC2 start/stop at set times daily
Are you incurring unnecessary costs for running AWS EC2 instances when they’re not needed?
For instance - you have a web application that is only used by your employees during the business hours i.e. say 8 to 9 hours every day. But you are charged for 24 hours each day. Based on the type of your instance, it can result in huge amounts of unnecessary extra costs for the duration your application is not even used.
You can use AWS Systems Manager to automatically start and stop your instances when they are not needed.
To do so, you can follow the steps below.
Tag your instance(s) that you want to automate.
Go to your EC2 dashboard.
Select the instance that you want to automate.
Click the Tags tab in the instance details section.
Click Manage Tabs button and add a tag name and value that you want to identify your instance for automation.
In this example I have used the tag name “Automate” and set it’s value to “Yes”. You can use any name/value pair as per your need.
Create a scheduler in the AWS Systems Manager to automate this instance.
Go to AWS Systems Manager console -https://console.aws.amazon.com/systems-manager
In the left navigation menu, click “Quick Setup” link.
Click Create button within the Resource Scheduler card.
In the Instance Tag section, enter the tag name and value that we defined in the instance’s settings above.
In the Schedule options section, select the time zone, days, and times that you want to start and stop your instances.
For example, in the screenshot below you can see that the schedule is defined for Monday to Friday from 09:00 AM to 05:00 PM.
In the Targets section, you can select whether you want to deploy the schedule in your current region or in specific regions.
You can verify the schedule information in the Summary section.
Finally, click the Create button to create your scheduler.
It might take a minute or two before the scheduler is ready. You can check this in the Resource Scheduler status.