GithubHelp home page GithubHelp logo

austra / amazon_start_stop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phstc/amazon_start_stop

1.0 2.0 0.0 86 KB

This is a sample "script" to schedule start and stop Amazon EC2 instances based on a date time range

Ruby 100.00%

amazon_start_stop's Introduction

Amazon start and stop

This is a sample "script" to schedule start and stop Amazon EC2 instances based on a date time range, i.e. start at 6AM and stop at 12AM.

Have a look at AWS Calculator to see how much you can save by stopping unsed instances from 12AM to 6AM (save 25%) or other date time ranges.

Usage

Checkout amazon_start_stop.

$ git clone [email protected]:austra/amazon_start_stop.git
$ cd amazon_start_stop

Heroku

  1. Create a Heroku account if don't have one and install the Heroku Toolbelt.
  2. Create a new app.
$ heroku apps:create

Deploy

$ git push heroku master

Configure Environment Variables

Configure your app settings using Heroku config vars.

Get your AWS credentials here: AWS Credentials.

Rename .env.sample to .env or Create a file named .env and add the following, customized to your needs:

# .env
AWS_ACCESS_KEY_ID=""
AWS_SECRET_ACCESS_KEY=""

# Leave blank if you don't need to associate an Elastic IP
# (everytime you stop an instance Amazon dissociates Elastic IPs)
AWS_ELASTIC_IP=""

# The instance id to start and stop i.e. i-1a1aa111
AWS_INSTANCE_ID=""
AWS_REGION="us-west-2"

LANG="en_US.UTF-8"
START_TIME="9:45pm"
STOP_TIME="10:45pm"
TIMEZONE="America/Denver"

Run the following to create the Herkou Environment Variables from your .env file.

$ heroku plugins:install git://github.com/ddollar/heroku-config.git
$ heroku config:push 

Heroku Scheduler

Add and configure Heroku Scheduler add-on standard (free add-on).

$ heroku addons:add scheduler:standard
$ heroku addons:open scheduler

In the Scheduler Dashboard add a new Scheduler.

TASK DYNO SIZE FREQUENCY
bin/amazon_start_stop 1x Every 10 minutes

Manual execution

In production.

$ heroku run bundle exec ruby bin/amazon_start_stop
# to check the script output
$ heroku logs

In development.

$ foreman start

amazon_start_stop's People

Contributors

austra avatar

Stargazers

Roman avatar

Watchers

 avatar James Cloos 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.