0

I want to create a web app for my organization where users can schedule in advance at what times they'd like their EC2 instances to start and stop (like creating events in a calendar), and those instances will be automatically started or stopped at those times. I've come across four different options:

  1. AWS Datapipeline
  2. Cron running on EC2 instance
  3. Scheduled scaling of Auto Scaling Group
  4. AWS Lambda scheduled events

It seems to me that I'll need a database to store the user's scheduled times for autostarting and autostopping an instance, and that I'll have to pull that data from the database regularly (to make sure that's the latest updated schedule). Which would be the best of the four above options for my use case?

Edit: Auto Scaling only seems to be for launching and terminating instances, so I can rule that out.

D. Stri
  • 1
  • 2

2 Answers2

3

Simple!

  1. Ask users to add a tag to their instance(s) indicating when they should start and stop (figure out some format so they can easily specify Mon-Fri or Every Day)
  2. Create an AWS Lambda function that scans instances for their tags and starts/stops them based upon the tag content
  3. Create an Amazon CloudWatch Event rule that triggers the Lambda function every 15 minutes (or whatever resolution you want)

You can probably find some sample code if you search for AWS Stopinator.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • 1
    Using Lambda function with Boto3 and cloudwatch rules is so easy: ec2 = boto3.client('ec2') ec2.stop_instances( InstanceIds = ['XXXXXXXXXX',XXXXXXXX] ) Here there is a complete example: https://www.dbigcloud.com/cloud-computing/220-automatiza-el-apagado-de-instancias-ec2-a-traves-de-lambdas-en-aws.html – drsromero Aug 08 '17 at 07:55
0

Take a look at ParkMyCloud if you're looking for an external SaaS app that can help your users easily schedule (or override that schedule) your EC2, RDS, and ASG instances. It also connects to SSO, provides an API, and shows you all of your resources across regions/accounts/clouds. There's a free trial available if you want to test it out.

Disclosure: I work for ParkMyCloud.

cparlette
  • 1
  • 1
  • 1
    This was flagged as spam. Are you connected with this company in any way? If you are, you must [disclose your affiliation](https://stackoverflow.com/help/promotion). – Russia Must Remove Putin Aug 08 '17 at 16:24