Cloud FinOps
10
mins read

Amazon EC2 Scheduling

Smart EC2 Scheduling to Maximize Efficiency and Minimize Costs
By
Sanika Kotgire
Document

Did you know?

AWS EC2 scheduling isn't just about a simple "on/off" switch; it's a critical component of a comprehensive FinOps strategy, enabling organizations to manage their cloud spend with surgical precision, reducing waste that could otherwise exceed 25-30% of their total cloud bill!

Are your EC2 instances running all the time, even when no one is using them?

This can lead to high and unnecessary costs. By using EC2 Scheduling, you can automatically start and stop your instances based on a set time, helping you save costs without manual effort.

In this blog, you’ll learn how to schedule EC2 instances using simple tools, when and why to use it, and how much you can save by avoiding idle usage.

What is EC2 Instance Scheduling?

EC2 instance scheduling is the process of automatically starting and stopping EC2 instances based on a defined timetable. It helps reduce costs by running instances only when needed, such as during business hours or specific workloads like development or testing.

Why Schedule EC2 Instances?

  • Reduce idle-time costs by stopping unused instances
  • Ideal for dev/test environments with working-hour needs
  • Eliminate human error via automation
  • Align compute time with business hours

How to Schedule EC2 Instances on AWS

Since Amazon EC2 does not offer built-in scheduling, you can use two reliable AWS-native methods to automatically start and stop instances based on your defined schedule:

1) Using AWS Instance Scheduler 

AWS Instance Scheduler is an official AWS solution that helps you automatically start and stop EC2 instances using pre-defined schedules.

AWS Instance Scheduler Pricing

While AWS Instance Scheduler is a free solution provided by AWS, it uses several AWS services that incur minimal charges.

Here's a breakdown of the typical monthly costs:

AWS Service Role Pricing (us-east-1) Monthly Estimate
AWS Lambda Scheduler logic every 5 minutes 1M free requests + 400K GB‑s free, then $0.20/1M requests + $0.000016667/GB‑s Free – <$1
CloudWatch Logs Stores Lambda logs $0.50 per GB ingested, $0.03 per GB stored ~$0.50 – $1
Amazon DynamoDB Configuration & schedule storage $0.25/GB‑month storage + $0.25/million RCU + $1.25/million WCU $1 – $3
SNS (optional) Sending schedule notifications $0.50 per million publishes <$0.10
S3 (optional) Hosting templates or backups ~$0.025 per GB/month Negligible
CloudFormation Infrastructure provisioning Free (you only pay for used resources)

Steps to Set UP AWS Instance Scheduler

Step 1: Download the CloudFormation Template

Step 2: Launch the CloudFormation Stack

  • Go to AWS Console → CloudFormation
  • Click Create Stack → With existing resources (template)
  • Choose Upload a template file and upload the .template you downloaded
  • Click Next


Step 3: Configure Stack Details

  • Stack Name: InstanceSchedulerStack (or any custom name)
  • Parameters to set:
Parameter Value
SchedulerFrequency 5 (default)
DefaultTimezone Asia/Kolkata
TagName Schedule
Regions Leave default or specify
StoppedNewInstances true

Click Next, then Create Stack

Step 4: Create a Schedule in DynamoDB

  • Go to DynamoDB → Find the table named config
  • Click Explore table items → Create item

Add two items (one for schedule and one for period):

 

-Schedule Item

{
  "type": { "S": "schedule" },
  "name": { "S": "work-hours" },
  "periods": { "L": [ { "S": "work-period" } ] },
  "timezone": { "S": "Asia/Kolkata" }
}

-Period Item

{
  "type": { "S": "period" },
  "name": { "S": "work-period" },
  "begintime": { "S": "09:00" },
  "endtime": { "S": "18:00" },
  "weekdays": {
    "L": [
      { "S": "mon" },
      { "S": "tue" },
      { "S": "wed" },
      { "S": "thu" },
      { "S": "fri" }
    ]
  }
}

Step 5: Tag Your EC2 Instances

  • Go to EC2 Console → Select an instance → Tags → Manage Tags
  • Add:
    • Key: Schedule
    • Value: work-hours
  • Click Save

Your EC2 instance is now scheduled to start at 9:00 AM and stop at 6:00 PM, Monday to Friday, automatically—saving you costs during off-hours.

Once you've set up EC2 scheduling, it's important to verify the active time window for each instance.

How to check or confirm the schedule:

DynamoDB 'config' table:

  1. Go to the DynamoDB table named config.
  2. Look for items where type = schedule and type = period.
  3. These items define the active time window (e.g., 09:00–18:00, Mon–Fri).
  4. You can also create multiple schedules and assign different ones to different EC2 instances via tags.

EC2 Tag ‘Schedule’:

  1. Go to the EC2 instance → Tags tab.
  2. Check the value of the Schedule tag (e.g., work-hours).
  3. Match this value with the schedule name defined in DynamoDB.

CloudWatch Logs (optional but useful):

  1. View logs of the Lambda functions executing the start/stop actions.
  2. This confirms whether the instance started/stopped as per the schedule.

2) Using Amazon EventBridge + Lambda

This method is more flexible and lightweight. You define a cron-based rule in EventBridge and use AWS Lambda to start or stop EC2 instances.

Pricing for Amazon EventBridge + Lambda

Automating EC2 instance start/stop using Amazon EventBridge and AWS Lambda is cost-effective and simple. Here's a breakdown of typical monthly costs:

AWS Service Role Monthly Cost Estimate (US East – N. Virginia)
Amazon EventBridge Triggers Lambda on a defined schedule (e.g., 9 AM & 6 PM daily) Free (1M events/month free)
AWS Lambda Executes EC2 start/stop function Free to <$1 (within 1M requests/month + 400K GB-seconds)
CloudWatch Logs Logs Lambda executions ~$0.50 – $1 (for ~1 GB of logs/month)

Steps to Set Up Amazon EventBridge + Lambda

Step 1: Create a Lambda Function

  1. Go to the Lambda console and create a new function.
  2. Choose Author from scratch.
  3. Runtime: Python 3.x (or Node.js, if you prefer)
  4. Paste the following sample code:
import boto3

ec2 = boto3.client('ec2')

def lambda_handler(event, context):
    ec2.start_instances(InstanceIds=['id'])

To stop instances, replace start_instances with stop_instances.

  1. Add permissions: Attach an IAM role with EC2 access (AmazonEC2FullAccess or scoped permissions).

Step 2: Create an EventBridge Rule

  1. Go to Amazon EventBridge.
  2. Create a rule with a schedule:
    • Name: StartEC2Morning
    • Rule type: Schedule
    • Schedule pattern:  cron(0 9 ? * MON-FRI *) — This triggers at 9 AM, Mon–Fri
  3. Set the target to the Lambda function you created.
  4. To stop instances in the evening, create another rule: cron(0 19 ? * MON-FRI *) — triggers at 7 PM

You now have a custom scheduling setup.

Which One Should You Choose?

Feature AWS Instance Scheduler EventBridge + Lambda
Setup Complexity Medium (CloudFormation + DynamoDB) Low to Medium (Lambda + Cron)
Best For Multi-instance, repeatable setups Custom logic, fewer instances
Coding Required No Yes
Flexibility Moderate (based on config) High (full control via code)
Multi-Account Support Yes Not by default

References

  1. AWS Instance Scheduler Documentation
  2. AWS Instance Scheduler GitHub Repository
  3. Amazon EC2 Pricing
  4. AWS Lambda Pricing
  5. Amazon EventBridge Pricing  

Conclusion

Amazon EC2 Scheduling is a powerful yet underused way to cut costs in your AWS environment, especially for dev, test, and staging workloads. Whether you choose the robust AWS Instance Scheduler or the lightweight and flexible EventBridge + Lambda setup, you can reduce idle compute time and realize savings of up to 70% on EC2 charges.

FAQs

Can I schedule EC2 instances without writing any code?

Yes. AWS Instance Scheduler uses a CloudFormation template and DynamoDB-based configuration, requiring no custom code. It's ideal for non-developers or teams looking for a plug-and-play EC2 automation solution.

Which is better for EC2 scheduling: AWS Instance Scheduler or EventBridge?

Use AWS Instance Scheduler for managing multiple instances across accounts with reusable schedules. Choose EventBridge + Lambda for a simpler, custom-coded setup that fits lightweight or flexible scheduling needs.

Does EC2 scheduling work across multiple AWS regions?

Yes, AWS Instance Scheduler supports multi-region and even multi-account scheduling. You can define region-specific rules and control instance schedules globally.

How do I check if my EC2 instance is scheduled correctly?

You can verify schedules via the DynamoDB config table (for AWS Instance Scheduler), CloudWatch Logs (to confirm start/stop actions), or by reviewing the Schedule tag on the EC2 instance.

What IAM permissions are required for EC2 scheduling?

For Lambda-based scheduling, attach an IAM role with permissions like AmazonEC2FullAccess.