Module :
awslambda
Version : 0.0.0
Module Overview
This module offers the capabilities of creating AWS Lambda functions using ballerina.
Annotation Usage Sample:
import ballerinax/awslambda;
import ballerina/system;
@awslambda:Function
public function echo(awslambda:Context ctx, json input) returns json|error {
return input;
}
@awslambda:Function
public function uuid(awslambda:Context ctx, json input) returns json|error {
return system:uuid();
}
@awslambda:Function
public function ctxinfo(awslambda:Context ctx, json input) returns json|error {
json result = { RequestID: ctx.getRequestId(),
DeadlineMS: ctx.getDeadlineMs(),
InvokedFunctionArn: ctx.getInvokedFunctionArn(),
TraceID: ctx.getTraceId(),
RemainingExecTime: ctx.getRemainingExecutionTime() };
return result;
}
The output of the Ballerina build is as follows:
$ ballerina build functions.bal
Compiling source
functions.bal
Generating executable
functions.jar
@awslambda:Function: echo, uuid, ctxinfo
Run the following command to deploy each Ballerina AWS Lambda function:
aws lambda create-function --function-name <FUNCTION_NAME> --zip-file fileb://aws-ballerina-lambda-functions.zip --handler functions.<FUNCTION_NAME> --runtime provided --role <LAMBDA_ROLE_ARN> --layers <BALLERINA_LAYER_ARN>
Run the following command to re-deploy an updated Ballerina AWS Lambda function:
aws lambda update-function-code --function-name <FUNCTION_NAME> --zip-file fileb://aws-ballerina-lambda-functions.zip
Context |
Object to represent an AWS Lambda function execution context. |
__process | |
__register |
Function |
@awslambda:Function annotation |