Lua runtime for AWS Lambda.
Luambda is a Lambda Layer that allows developers to write Lambdas using Lua. To get started, read through the rest of this readme.
- Download
luambda.zip
from the latest release - Go to the Create Layer page on the AWS console
- Name the layer
Luambda
- Click the Upload button and select the
luambda.zip
file from the unzipped release - In the Runtimes dropdown, select "Custom runtime"
- Under license, write MIT
- Click the Create button
- Download
luambda.zip
from the latest release - Upload the
luambda.zip
file to S3 - Use the
luambda.yaml
CF template to create the new stack
# Clone repo
$ git clone https://github.com/Sleitnick/Luambda
$ cd Luambda
# Executable permissions
$ chmod +x build.sh compile.sh
# Package and upload to S3
$ ./build.sh
$ aws s3 cp dist/luambda.zip s3://<upload_bucket>/<optional_path>/luambda.zip
# Create Lambda Layer
$ aws cloudformation create-stack --stack-name LuambdaLayer --template-body file://aws/luambda.yaml --paramters ParameterKey=S3Bucket,ParameterValue=<s3_bucket> ParameterKey=S3Key,ParameterValue=<s3_key>
Warning for Windows users using option 3: The zip file created from the build.sh
script may not work properly on Windows, because it will strip the permissions from the files, which will lead to errors when attempting to execute the lambda.
For your Lambda configuration, add Luambda as a layer.
The Handler
property of your lambda follows the syntax of [script_name].[function_name]
. The script should return a table that contains that function. For instance, if the handler was set as test.handler
, then the code would look like this:
-- test.lua
local test = {}
function test.handler(event)
return {
Ok = "All good";
}
end
return test
By default, Luambda uses LuaJIT, a JIT compiler for Lua. To use a different version, drop in the binaries under /runtime
and then change the bootstrap
file to point to the different binary.
For instance, you might change /opt/runtime/luajit
in the bootstrap
file to /opt/runtime/lua51
.
The following third-party dependencies are used: