From c3e31ca449edf0ac2affab33ae2ee6bf3f46d360 Mon Sep 17 00:00:00 2001 From: davidwells Date: Tue, 11 Oct 2016 00:46:56 -0700 Subject: [PATCH] add cron example --- docs/02-providers/aws/examples/cron/README.md | 12 ++++++++++++ .../aws/examples/cron/node/README.md | 18 ++++++++++++++++++ .../aws/examples/cron/node/handler.js | 6 ++++++ .../aws/examples/cron/node/serverless.yml | 11 +++++++++++ 4 files changed, 47 insertions(+) create mode 100644 docs/02-providers/aws/examples/cron/README.md create mode 100644 docs/02-providers/aws/examples/cron/node/README.md create mode 100644 docs/02-providers/aws/examples/cron/node/handler.js create mode 100644 docs/02-providers/aws/examples/cron/node/serverless.yml diff --git a/docs/02-providers/aws/examples/cron/README.md b/docs/02-providers/aws/examples/cron/README.md new file mode 100644 index 000000000..94d45863a --- /dev/null +++ b/docs/02-providers/aws/examples/cron/README.md @@ -0,0 +1,12 @@ + + +# Schedule Cron + +Create a scheduled task with AWS lambda and automate all teh things! + +For more information on running cron with serverless check out the [Tutorial: Serverless Scheduled Tasks](https://parall.ax/blog/view/3202/tutorial-serverless-scheduled-tasks) by parrallax. \ No newline at end of file diff --git a/docs/02-providers/aws/examples/cron/node/README.md b/docs/02-providers/aws/examples/cron/node/README.md new file mode 100644 index 000000000..3b92da677 --- /dev/null +++ b/docs/02-providers/aws/examples/cron/node/README.md @@ -0,0 +1,18 @@ + + +# AWS Lambda Node Cron Function + +This is an example of creating a function that runs on a scheduled cron. + +To see your cron running tail your logs with: + +```bash +serverless logs -function cron -tail +``` + +[Tutorial: Serverless Scheduled Tasks](https://parall.ax/blog/view/3202/tutorial-serverless-scheduled-tasks) \ No newline at end of file diff --git a/docs/02-providers/aws/examples/cron/node/handler.js b/docs/02-providers/aws/examples/cron/node/handler.js new file mode 100644 index 000000000..3076e32d0 --- /dev/null +++ b/docs/02-providers/aws/examples/cron/node/handler.js @@ -0,0 +1,6 @@ +'use strict' + +module.exports.run = (event, context, callback) => { + const time = new Date() + console.log(`Your cron ran ${time}`) +} \ No newline at end of file diff --git a/docs/02-providers/aws/examples/cron/node/serverless.yml b/docs/02-providers/aws/examples/cron/node/serverless.yml new file mode 100644 index 000000000..e626957bc --- /dev/null +++ b/docs/02-providers/aws/examples/cron/node/serverless.yml @@ -0,0 +1,11 @@ +service: cron-example # This is the name of your service +provider: + name: aws # This is the provider we’re deploying to + runtime: nodejs4.3 # You have a choice of Node, Java, or + # Python, but you can run native binaries too +functions: + cron: + handler: handler.run # This will require the handler.js file, + # and execute the exported run function + events: + - schedule: rate(1 minute) \ No newline at end of file