fourth44 / aws-lambda-scala

Writing AWS Lambdas in Scala

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Codacy Badge Build Status Maven Central

Writing a handler for AWS lambda in Scala can be as easy as...

package io.github.mkotsur.example

import io.github.mkotsur.aws.handler.LambdaHandler
import io.circe.generic.auto._

case class Ping(inputMsg: String)

case class Pong(outputMsg: String)

class PingPongHandler extends LambdaHandler[Ping, Pong] {

  override def handle(ping: Ping) = Right(Pong(ping.inputMsg.reverse))

}

The input JSON will be automatically deserialized into Ping, and the output into Pong. The handle() method is supposed to return Either[Throwable, Pong]: Right if the input was handled correctly, and Left otherwise.

This handler can be used in AWS Lambda as: io.github.mkotsur.example::handle.

Features:

Docs are coming soon... Feel free to look at src/test/scala if you want to use it right now.

Adding to your project

libraryDependencies += "io.github.mkotsur" % "aws-lambda-scala_2.12" % "0.0.5"

Lessons learned

Don't define a companion object for the handler class. AWS won't appreciate that.

About

Writing AWS Lambdas in Scala


Languages

Language:Scala 100.0%