diff --git a/README.md b/README.md index 0b100c5..63af8d6 100644 --- a/README.md +++ b/README.md @@ -24,3 +24,4 @@ Each example contains a README.md with an explanation about the solution and it' | [`five-minute-serverless-backend`](five-minute-serverless-backend)
Build a serverless web backend in 5 minutes | nodeJS | | [`quines`](quines)
A small collection of self-replicating functions | nodeJS and python2 | | [`python-crud-google-spreadsheet`](python-crud-google-spreadsheet)
Google Spreadsheet CRUD with functions | python3 | +| [`lambda-binaris-wrapper`](lambda-binaris-wrapper)
Run AWS Lambda code directly on Binaris | nodeJS | diff --git a/lambda-binaris-wrapper/README.md b/lambda-binaris-wrapper/README.md new file mode 100644 index 0000000..6eb6b51 --- /dev/null +++ b/lambda-binaris-wrapper/README.md @@ -0,0 +1,16 @@ +# Lambda wrapper example + +This example demonstrates how to deploy a Binaris function that will run Lambda code. + +### Usage + +```bash +$ npm install +$ bn deploy wrapped_lambda +$ bn invoke wrapped_lambda + "Hello serverless!" +``` + +If you have existing Lambda code you would like to use, simply replace the contents of `handler.js`. + +> Note: If your Lambda code has a different entrypoint, remember to update the `binaris.yml` \ No newline at end of file diff --git a/lambda-binaris-wrapper/binaris.yml b/lambda-binaris-wrapper/binaris.yml new file mode 100644 index 0000000..79d38b5 --- /dev/null +++ b/lambda-binaris-wrapper/binaris.yml @@ -0,0 +1,9 @@ +functions: + wrapped_lambda: + file: function.js + entrypoint: handler + executionModel: concurrent + runtime: node8 + env: + LAMBDA_FILE_PATH: 'handler.js' + LAMBDA_HANDLER: 'hello' diff --git a/lambda-binaris-wrapper/function.js b/lambda-binaris-wrapper/function.js new file mode 100644 index 0000000..8dae19a --- /dev/null +++ b/lambda-binaris-wrapper/function.js @@ -0,0 +1,5 @@ +const { wrapLambda } = require('./node_modules/lambda-binaris-wrapper/lib/index.js'); + +const { LAMBDA_FILE_PATH, LAMBDA_HANDLER } = process.env; + +exports.handler = wrapLambda(LAMBDA_FILE_PATH, LAMBDA_HANDLER); diff --git a/lambda-binaris-wrapper/handler.js b/lambda-binaris-wrapper/handler.js new file mode 100644 index 0000000..ad03eb4 --- /dev/null +++ b/lambda-binaris-wrapper/handler.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports.hello = async (event, context) => { + return 'Hello serverless!'; +}; diff --git a/lambda-binaris-wrapper/package.json b/lambda-binaris-wrapper/package.json new file mode 100644 index 0000000..35d1099 --- /dev/null +++ b/lambda-binaris-wrapper/package.json @@ -0,0 +1,30 @@ +{ + "name": "lambda-binaris-wrapper", + "version": "1.0.0", + "private": true, + "license": "MIT", + "description": "Invoke existing AWS Lambdas as Binaris functions", + "main": "function.js", + "repository": { + "type": "git", + "url": "git+https://github.com/binaris/functions-examples.git" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "bugs": { + "url": "https://github.com/binaris/functions-examples/issues" + }, + "homepage": "https://github.com/binaris/functions-examples/lambda-binaris-wrapper/README.md", + "author": "Ryland Goldstein", + "dependencies": { + "@binaris/lambda-binaris-wrapper": "^1.0.0-rc.1" + }, + "keywords": [ + "Binaris", + "Slack", + "FaaS", + "Pi", + "Command" + ] +}