|
| 1 | + |
| 2 | + |
| 3 | +# API-Builder AWS-Lambda Flow-Node |
| 4 | + |
| 5 | +If you would like to integrate AWS Lambda functions into your [API-Builder flow][1] use this flow node. |
| 6 | +It allows you to easily call your Lambda-Functions and merge, transform or use the returned data in any way you want. |
| 7 | + |
| 8 | +## Configuration |
| 9 | + |
| 10 | +After installation and restarting your API-Builder project you get the following new flow-node: |
| 11 | +![Node][img1] |
| 12 | +Before you can make use it in your flow you have to configure your AWS-Credentials allowed to invoke Lambda functions. |
| 13 | + |
| 14 | +During installation a new config file has been automatically created which must be completed with your AWS Credentials. You can do that directly from within the API-Builder UI: |
| 15 | +![Config][img3] |
| 16 | +We recommend to setup your configuration in a [environmentalized][4] way keeping [sensitive information][5] away from the source-code repository. |
| 17 | + |
| 18 | +## Invoke Lambda functions |
| 19 | +To invoke a Lambda function, just drag & drop the Flow-Node into your flow and set it up as described here. |
| 20 | +![Node][img2] |
| 21 | + |
| 22 | +### Input parameters |
| 23 | + |
| 24 | +| Param | Type | Required | Description | |
| 25 | +| --- | --- | --- | --- | |
| 26 | +| func | string | y | The name of the AWS-Lambda-Function to call. | |
| 27 | +| payload | JSON or Object | n | Input information required by the Lambda-Function. Example: `{"key1":"value1"}` | |
| 28 | +| asynchronous | boolean | n | If enabled the Lambda function is invoked asyncronously and no data is returned. Read more here: https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html. | |
| 29 | +| logResult | boolean | n | If enabled, the Tail option is used when invoking the Lambda function and logged in the API Builder Console. | |
| 30 | + |
| 31 | +### Output |
| 32 | +If the function wasn't invoked asynchronously you get back the `data.Payload` into attribute configured with next. By default: `$.result`. For example, having the following AWS-Lambda function: |
| 33 | +```js |
| 34 | +exports.handler = async (event) => { |
| 35 | + const response = { |
| 36 | + statusCode: 200, |
| 37 | + body: "Hello from " + event.key1 + " from AWS-Lambda!" |
| 38 | + }; |
| 39 | + return response; |
| 40 | +}; |
| 41 | +``` |
| 42 | +Using the payload: `{"key1":"Chris"}` the attribute `$.result` will contain the following: `Howdy Hello from Chris from AWS-Lambda!`. |
| 43 | +In case of an error the attribute: `$.error` contains the error returned by AWS or by the Lambda-Fow-Node. |
| 44 | + |
| 45 | +If the function is invoked asynchronously no data is returned. The attribute: `$.result` just contains the value: `Accepted`. |
| 46 | + |
| 47 | +## Compatibility |
| 48 | +Tested with AWS Lambda Q1/2020 |
| 49 | +Requires API-Builder Independence or higher |
| 50 | + |
| 51 | +## Changelog |
| 52 | +- 1.0.0 - 18.02.2020 |
| 53 | + - Initial version |
| 54 | + |
| 55 | +## Limitations/Caveats |
| 56 | +Noting known |
| 57 | + |
| 58 | +## Contributing |
| 59 | + |
| 60 | +Please read [Contributing.md](https://github.com/Axway-API-Management-Plus/Common/blob/master/Contributing.md) for details on our code of conduct, and the process for submitting pull requests to us. |
| 61 | + |
| 62 | +## Team |
| 63 | + |
| 64 | +![alt text][Axwaylogo] Axway Team |
| 65 | + |
| 66 | +[Axwaylogo]: https://github.com/Axway-API-Management/Common/blob/master/img/AxwayLogoSmall.png "Axway logo" |
| 67 | + |
| 68 | +[1]: https://docs.axway.com/bundle/API_Builder_4x_allOS_en/page/api_builder_flows.html |
| 69 | +[2]: https://docs.axway.com/bundle/API_Builder_4x_allOS_en/page/api_builder_getting_started_guide.html |
| 70 | +[3]: https://github.com/Axway-API-Builder-Ext/api-builder-extras/issues |
| 71 | +[4]: https://docs.axway.com/bundle/API_Builder_4x_allOS_en/page/environmentalization.html |
| 72 | +[5]: https://docs.axway.com/bundle/API_Builder_4x_allOS_en/page/project_configuration.html#ProjectConfiguration-Configurationfiles |
| 73 | + |
| 74 | +[img1]: imgs/lambda-flownode.png |
| 75 | +[img2]: imgs/lambda-invoke.png |
| 76 | +[img3]: imgs/Lambda-Connector-Config.png |
| 77 | +[img4]: imgs/Lambda-Connector-Config-File.png |
0 commit comments