mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Added Lambda Node support as part of the regular functions workflow. (#601)
* Added Lambda Node support as part of the regular functions workflow. * Fixes for PR comments.
This commit is contained in:
committed by
Seif Lotfy سيف لطفي
parent
0492ca5dfb
commit
ca18ae88fa
2
examples/lambda/node/.gitignore
vendored
Normal file
2
examples/lambda/node/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
func.yaml
|
||||
/node_modules
|
||||
13
examples/lambda/node/README.md
Normal file
13
examples/lambda/node/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Lambda Node Example
|
||||
|
||||
This is the exact same function that is in the AWS Lambda tutorial.
|
||||
|
||||
Other than a different runtime, this is no different than any other node example.
|
||||
|
||||
To use the lambda-node runtime, use this `fn init` command:
|
||||
|
||||
```sh
|
||||
fn init --runtime lambda-node <DOCKER_HUB_USERNAME>/lambda-node
|
||||
fn build
|
||||
cat payload.json | fn run
|
||||
```
|
||||
12
examples/lambda/node/func.js
Normal file
12
examples/lambda/node/func.js
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
console.log('Loading function');
|
||||
|
||||
exports.handler = (event, context, callback) => {
|
||||
//console.log('Received event:', JSON.stringify(event, null, 2));
|
||||
console.log('value1 =', event.key1);
|
||||
console.log('value2 =', event.key2);
|
||||
console.log('value3 =', event.key3);
|
||||
callback(null, event.key1); // Echo back the first key value
|
||||
//callback('Something went wrong');
|
||||
};
|
||||
5
examples/lambda/node/payload.json
Normal file
5
examples/lambda/node/payload.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"key3": "value3",
|
||||
"key2": "value2",
|
||||
"key1": "value1"
|
||||
}
|
||||
Reference in New Issue
Block a user