The helper library to invoke AWS Lambda functions from agent code.
To add this library to your model, add the following lines to the top of your agent code:
#require "AWSRequestV4.class.nut:1.0.2"
#require "AWSLambda.class.nut:1.0.0"
Note: AWSRequestV4 must be included.
AWSLambda object constructor takes the following parameters:
Parameter | Type | Description |
---|---|---|
region | string | AWS region (e.g. "us-west-1") |
accessKeyId | string | IAM Access Key ID |
secretAccessKey | string | IAM Secret Access Key |
#require "AWSRequestV4.class.nut:1.0.2"
#require "AWSLambda.class.nut:1.0.0"
const AWS_LAMBDA_REGION = "us-west-1";
const ACCESS_KEY_ID = "YOUR_ACCESS_KEY_ID";
const SECRET_ACCESS_KEY = "YOUR_SECRET_ACCESS_KEY";
lambda <- AWSLambda(AWS_LAMBDA_REGION, ACCESS_KEY_ID, SECRET_ACCESS_KEY);
Invokes lambda function. Please refer to the AWS Lambda documentation for more details.
The function takes the following parameters:
Parameter | Type | Description |
---|---|---|
params | table | Table of parameters (See API Reference) |
callback | function | Callback function that takes one parameter (response table) |
where params
include:
Parameter | Type | Required | Default Value | Description |
---|---|---|---|---|
functionName | string | yes | N/A | Name of the Lambda function to be called |
payload | serializable data | yes | N/A | Data that you want to provide to your Lambda |
contentType | string | no | "application/json" | The payload content type |
local payload = { "message" : "Hello, world!" };
local params = { "payload" : payload, "functionName" : "mySend" };
lambda.invoke(params, function (result) {
local payload = http.jsondecode(result.body);
if ("Message" in payload) {
server.error(payload.Message);
} else {
server.log("[SUCCESS]: " + payload.transmit);
}
}.bindenv(this))
The AWSLambda library is licensed under the MIT License.