Functions

You can write and place simple Lambda functions in the app/functions folder. A simple lambda function looks like this:

app/functions/simple.rb:

require 'json'
def lambda_handler(event:, context:)
  puts "event: #{JSON.dump(event)}"
  puts "hello world"
  {foo: "bar"}
end

The default handler is named lambda_handler. Once deployed, the lambda function shows up in the Lambda console like this:

You can run the function in the AWS Lambda console and see the results:

Here’s an article that covers writing a simple lambda function with Jets: Jets Simple AWS Lambda Ruby Function.

Though manually creating simple Lambda functions is possible with Jets, the full power of Jets is in automatically generating the Lambda functions that your API requires. Your API’s Lambda functions are defined for you behind the scenes when you use Jets Controllers and Jobs. These classes give you many conveniences methods to make your life easier. We’ll cover them next.

Pro tip: Use the <- and -> arrow keys to move back and forward.

Edit this page

See a typo or an error? You can improve this page. This website is available on GitHub, and contributions are encouraged and welcomed. We love pull requests from you!