Skeddly Blog

Skeddly news and announcements...

Automatically Shutdown Unused EC2 Instances at Night

Not all EC2 instances need to be running 24 hours a day, 7 days a week. Many instances are only used during business hours, Monday to Friday.

Here’s an easy way to configure your EC2 instances using EC2 tags to shutdown at night, restart in the morning, and only run on weekdays (Monday to Friday).

If you haven’t done so already, create a Skeddly account and register your AWS credentials.

First, we’ll create a Daily Start EC2 Instance schedule.

  1. Go to the Actions page by clicking the “Actions” tab.

  2. Click “Create New Action” and select “Start Multiple EC2 Instances”. You can also type “multiple ec2” in the Search box to find the action type faster.

  3. Give your action a name like “Weekday EC2 Starts”.

  4. Select your desired time of day that you want the instance to start, and select “Daily” for the Repeat Type. Also ensure that Monday through Friday is checked, but Saturday and Sunday are unchecked. This way, the schedule will not run on weekends.

  5. For “Instance Identification Method”, select “By EC2 Tag”. Type “Start” for the “EC2 Tag Name” with “Equals” and “Weekdays” for the “EC2 Tag Value”.

  6. We also want this action to stop the instance, so check “Stop the Instances” and for “Running Duration”, put the amount of time the instances should be running. For example, if you want your instances to start at 9:00 am and shutdown at 5:00 pm, put “8 Hours” for the “Running Duration”.

  7. Save your action.

The action is ready to go, however, you should ensure your AWS credentials are permitted to execute everything needed by Skeddly.

  1. Go to the Credentials page by clicking the “Credentials” tab.

  2. Click the name of your credentials to go to the “View” page for the credentials.

  3. Click the button labelled “Create IAM Policy Document”. This will generate an IAM policy document with just enough permissions to create your snapshots. Go to the AWS Management Console and update the policy on your credentials with this document.

Skeddly is all ready to start your EC2 instances. If everything is done correctly, you should never need to reconfigure Skeddly again.

Now, we’ll add some EC2 instances to our daily startup schedule.

  1. Go to the EC2 portion of the AWS Management Console.

  2. Select the “Instances” section along the left side to view your list of EC2 instances.

  3. Select an EC2 instance you want to start.

  4. Select the “Tags” tab in the details area below the instance list and click the “Add/Edit Tags” button.

  5. Add a new tag called “Start” with a value of “Weekdays”. Save your new tag.

Now this instance will start and stop daily, weekdays only.

To add more instances to the weekday schedule, simply add the “Start” tag to each instance with the value “Weekdays”.

<