Lambda function to automaticaly stop and start the EC2 instance.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.npmignore
README.md
package.json
serverless.yml
start.py
stop.py
yarn.lock

README.md

dawn

Lambda function to automaticaly stop and start the EC2 instance.

Prerequisite

Usage

Set AWS credentials and region

Set environment variable AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_REGION.

$ direnv edit . # direnv is not required
export AWS_ACCESS_KEY_ID=AKIAXXXXXXXXXXXXXXXXXX
export AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXX
export AWS_REGION=ap-northeast-1

Deploy Lambda Functions

Clone this repo.

$ git clone https://github.com/enokawa/dawn.git

Install dependencies.

$ cd dawn
$ yarn

Deploy.

$ yarn run deploy

Set Tag for EC2 Instance

like...

Key Value
dawn enable

Change Schedule

Edit cron(0 9 ? * * *) in serverless.yml.
Caution!! scheduled events use UTC time zone. See Schedule Expressions for Rules - Amazon CloudWatch Events.

Invoke functions manually

$ yurn run start
$ yurn run stop

Remove funtions

$ yarn run remove

Inspired by ...

https://github.com/y13i/amirotate