import ballerinax/awslambda;
import ballerina/system;
import ballerina/io;
@awslambda:Function
public function echo(awslambda:Context ctx, json input) returns json {
return input;
}@awslambda:Function
public function uuid(awslambda:Context ctx, json input) returns json {
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;
}@awslambda:Function
public function notifySQS(awslambda:Context ctx,
awslambda:SQSEvent event) returns json {
return event.Records[0].body;
}@awslambda:Function
public function notifyS3(awslambda:Context ctx,
awslambda:S3Event event) returns json {
return event.Records[0].s3.'object.key;
}@awslambda:Function
public function notifyDynamoDB(awslambda:Context ctx,
awslambda:DynamoDBEvent event) returns json {
return event.Records[0].dynamodb.Keys.toString();
}@awslambda:Function
public function notifySES(awslambda:Context ctx,
awslambda:SESEvent event) returns json {
return event.Records[0].ses.mail.commonHeaders.subject;
}@awslambda:Function
public function apigwRequest(awslambda:Context ctx,
awslambda:APIGatewayProxyRequest request) {
io:println("Path: ", request.path);
}# Prerequisites: AWS CLI tools installation and configuration
AWS Lambda DeploymentAWS Lambda is an event driven, serverless computing platform.
Ballerina functions can be deployed in AWS Lambda by annotating a
a Ballerina function with “@awslambda:Function”, which should have
the function signature |
|
|
|
The |
|
|
|
The |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|