{"id":15675271,"url":"https://github.com/phstc/amazon_start_stop","last_synced_at":"2025-05-06T23:43:18.495Z","repository":{"id":12958706,"uuid":"15637023","full_name":"phstc/amazon_start_stop","owner":"phstc","description":"This is a sample \"script\" to schedule start and stop Amazon EC2 instances based on a date time range","archived":false,"fork":false,"pushed_at":"2014-01-06T13:18:49.000Z","size":216,"stargazers_count":13,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T04:11:15.192Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phstc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-04T18:15:33.000Z","updated_at":"2018-12-24T04:39:20.000Z","dependencies_parsed_at":"2022-09-10T08:11:39.802Z","dependency_job_id":null,"html_url":"https://github.com/phstc/amazon_start_stop","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Famazon_start_stop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Famazon_start_stop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Famazon_start_stop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Famazon_start_stop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phstc","download_url":"https://codeload.github.com/phstc/amazon_start_stop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252788388,"owners_count":21804280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T15:58:06.606Z","updated_at":"2025-05-06T23:43:18.473Z","avatar_url":"https://github.com/phstc.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Amazon start and stop\n\nThis is a sample \"script\" to schedule start and stop [Amazon EC2 instances](https://aws.amazon.com/) based on a date time range, i.e. start at 6AM and stop at 0AM.\n\nHave a look at [AWS Calculator](https://calculator.s3.amazonaws.com/calc5.html) to see how much you can save by stopping unsed instances from 0AM to 6AM (save 25%) or other date time ranges.\n\n\n## Usage\n\n### Checkout amazon_start_stop.\n\n```bash\n$ git clone git@github.com:phstc/amazon_start_stop.git\n$ cd amazon_start_stop\n```\n\nEdit [bin/amazon_start_stop](https://github.com/phstc/amazon_start_stop/blob/master/bin/amazon_start_stop) and set the constants `START_HOUR` and `STOP_HOUR` as you need.\n\n```ruby\n# bin/amazon_start_stop\nSTART_HOUR = 6 # Start 6AM\nSTOP_HOUR  = 0 # Stop  0AM (midnight)\n```\n\n### Heroku\n\n1. Create a [Heroku account](https://www.heroku.com/) if don't have one and install the [Heroku Toolbelt](https://toolbelt.heroku.com/).\n2. Create a [new app](https://devcenter.heroku.com/articles/creating-apps).\n\n```bash\n$ heroku apps:create\n```\n\n### Deploy\n\n```bash\n$ git push heroku master\n```\n\n### AWS Credentials\n\nConfigure your [AWS Credentials](http://aws.amazon.com/iam/) using [Heroku config vars](https://devcenter.heroku.com/articles/config-vars).\n\n```bash\n$ heroku config:set AWS_ACCESS_KEY_ID=\n$ heroku config:set AWS_SECRET_ACCESS_KEY=\n\n# The instance id to start and stop i.e. i-1a1aa111\n$ heroku config:set AWS_INSTANCE_ID=\n\n# Leave blank if you don't need to associate an Elastic IP\n# (everytime you stop an instance Amazon dissociates Elastic IPs)\n$ heroku config:set AWS_ELASTIC_IP=\n```\n\nIn development create an `.env`.\n\n```bash\n# .env\nAWS_ACCESS_KEY_ID=\nAWS_SECRET_ACCESS_KEY=\nAWS_INSTANCE_ID=\nAWS_ELASTIC_IP=\n```\n\n### Heroku Scheduler\n\nAdd and configure [Heroku Scheduler add-on standard](https://devcenter.heroku.com/articles/scheduler) (free add-on).\n\n```bash\n$ heroku addons:add scheduler:standard\n$ heroku addons:open scheduler\n```\n\nIn the Scheduler Dashboard add a new Scheduler.\n\n| TASK                    | DYNO SIZE  | FREQUENCY        |\n| ----------------------- |:----------:| ----------------:|\n| bin/amazon_start_stop   | 1x         | Every 10 minutes |\n\n### Manual execution\n\nIn production.\n\n```bash\n$ heroku run bundle exec ruby bin/amazon_start_stop\n# to check the script output\n$ heroku logs\n```\n\nIn development.\n\n```bash\n$ foreman start\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphstc%2Famazon_start_stop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphstc%2Famazon_start_stop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphstc%2Famazon_start_stop/lists"}