Skip to content

Sleitnick/Luambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lint Release

logo

Luambda

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.

Create Layer

Option 1 - From the latest release:

  1. Download luambda.zip from the latest release
  2. Go to the Create Layer page on the AWS console
  3. Name the layer Luambda
  4. Click the Upload button and select the luambda.zip file from the unzipped release
  5. In the Runtimes dropdown, select "Custom runtime"
  6. Under license, write MIT
  7. Click the Create button

Option 2 - From latest release & use CloudFormation:

  1. Download luambda.zip from the latest release
  2. Upload the luambda.zip file to S3
  3. Use the luambda.yaml CF template to create the new stack

Option 3 - For a full custom build, execute the following commands:

# 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.

Use Layer

For your Lambda configuration, add Luambda as a layer.

Setup

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

Different Lua Versions

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.

Third-Party

The following third-party dependencies are used: