Coder Social home page Coder Social logo

aws-ec2-start-stop's Introduction

AWS EC2 start/stop functions

It's been surprisingly hard to schedule AWS EC2 instances launches/stops. This repo contains a set of artifacts to make it working in 10 minutes for simple cases when you need to launch/terminate a few instances. The following installation guide describes how to end up having an instance launched on working days at 09:45 and terminating at 10:10. Inspired by https://blog.goodmirek.com/periodically-start-and-stop-ec2-instance-bf25c01e68f1

Installation

  1. Create a new IAM policy ec2_start_stop_policy using ec2_start_stop_policy.json
  2. Create a new IAM role ec2_start_stop_role using ec2_start_stop_role.json
  3. Create a new lambda function ec2-start, use ec2_start_stop_role as the default execution role and lambda/ec2-start/index.js as source code. Put your instance id and region into the source code.
  4. Create a new lambda function, use ec2_start_stop_role as the default execution role and lambda/ec2-stop/index.js as source code. Put your instance id and region into the source code
  5. Create a new rule in CloudWatch rules ec2-start. Use ec2_start_stop_role and ec2-start function as a target. Use 45 9 ? * MON-FRI * as a schedule expression
  6. Create a new rule in CloudWatch rules ec2-stop. Use ec2_start_stop_role and ec2-stop function as a target. Use 10 10 ? * MON-FRI * as a schedule expression
  7. If you need hibernation instead of termination use lambda/ec2-hibernate/index.js at step 4

Further enhancements

  • make instance ids and region configurable
  • make CloudFormation templates to do the job

aws-ec2-start-stop's People

Contributors

ffeast avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.