All Collections
Getting Started
Amazon Web Services
Starting and Stopping EC2 Instances Daily
Starting and Stopping EC2 Instances Daily

Create an action to start and stop multiple EC2 instances

Matt Houser avatar
Written by Matt Houser
Updated over a week ago

Using Skeddly, you can setup a daily schedule such that your EC2 instances are turned off overnight and on weekends. There are many ways to do this, here we'll show one of the most flexible methods.
​ 
Here, we are going to use a single "Start Multiple EC2 Instances" action to create an action that will start EC2 instances at 8 AM and stop them at 7 PM. Each morning, Skeddly will look for EC2 instances in your selected region that has a resource tag named "skeddly:start-schedule" and value "0800".
​ 
Once configured, you can add EC2 instances to your schedule by simply adding the resource tag to your EC2 instance. This can be accomplished using CloudFormation or other DevOps tools.

Prerequisites

  • A Skeddly account

  • An AWS credential (IAM role or IAM access key) registered with Skeddly

Setting Up Skeddly

  1. Go to the Actions list by clicking "Actions" then "Actions".

2. Click the "Create New Action" button.
3. In the action list, find and click on "Start Multiple EC2 Instances".
4. In the "Name" field, give your action a friendly name. This is for your reference.
5. In the "Time of Day" field, put 8:00 AM. This will be the time that the EC2 instances will start.
6. In the "Time Zone" field, choose your local time zone. The EC2 instance will start at 8:00 AM in the selected time zone.
7. Set the "Repeat Type" field to be "Daily".
8. In the "Days of the Week" field, choose Monday, Tuesday, Wednesday, Thursday and Friday. Leave Saturday and Sunday unselected.

So far, we have defined our schedule so that it will execute daily at 8:00 AM, but only Monday through Friday.

9. In the "Credentials and Region" section, select the AWS credentials and AWS region in which your EC2 instances live.

Now we are going to define how Skeddly will select the EC2 instances to start.

10. In the "Instance Identification Method" field, choose "EC2 Tag". This tells the action to find EC2 instances by matching resource tags.
11. In the "EC2 Tag Name", put "skeddly:start-schedule". This is the name of the resource tag that will be used to find EC2 instances to start.
12. In the "EC2 Tag Value", put "Equals" and "0800". This is the value of the resource tag that must match.

At this time, the action is now configured to start EC2 instances, but it will not stop them yet.

13. In the "Stop the Instances" field, check the checkbox.
14. For "Running Duration", use a value of 11 Hours because 8 AM to 7PM is 11 hours.
15. Click the "Save" button.

The action is complete.

However, by default, Skeddly won't have permissions to execute this action yet. So we need to use Skeddly's IAM Policy Generator to generate a new policy. Instructions for that can be found here: IAM Policy Generator

Adding EC2 Instances to Your Schedule

Each morning, Monday through Friday, Skeddly will execute our action and it will look for EC2 instances to start. To add EC2 instances to this schedule, do the following in the AWS Management Console:
​ 

1. Go to the EC2 Management Console.
2. Go to the Instances list by clicking "Instances" on the left navigation pane.
3. Select the EC2 instance you want to add to the schedule.
4. In the details panel, click the "Tags" tab. This should show the list of existing resource tags.
5. Click the button titled "Add/Edit Tags".
6. Click the "Create Tag" button. A blank tag row should appear in the grid.
7. In the "Key" column, put "skeddly:start-schedule".
8. In the "Value" column, put "0800".
9. Click the "Save" button.

Remember, tag comparison is case-sensitive.

Did this answer your question?