{"id":28403678,"url":"https://github.com/mkotsur/aws-lambda-scala","last_synced_at":"2025-06-27T08:32:04.663Z","repository":{"id":54741785,"uuid":"72681162","full_name":"mkotsur/aws-lambda-scala","owner":"mkotsur","description":"Writing AWS Lambdas in Scala","archived":false,"fork":false,"pushed_at":"2024-08-20T10:09:39.000Z","size":35421,"stargazers_count":143,"open_issues_count":6,"forks_count":22,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-06-02T04:17:13.525Z","etag":null,"topics":["aws-lambda","cloud","json","scala","serverless"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mkotsur.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"ko_fi":"mkotsur","custom":"paypal.me/mkotsur"}},"created_at":"2016-11-02T21:03:31.000Z","updated_at":"2025-03-04T10:38:17.000Z","dependencies_parsed_at":"2025-06-01T19:07:30.126Z","dependency_job_id":"158e8989-b17c-4a1d-906e-30b8b43ec405","html_url":"https://github.com/mkotsur/aws-lambda-scala","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/mkotsur/aws-lambda-scala","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkotsur%2Faws-lambda-scala","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkotsur%2Faws-lambda-scala/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkotsur%2Faws-lambda-scala/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkotsur%2Faws-lambda-scala/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkotsur","download_url":"https://codeload.github.com/mkotsur/aws-lambda-scala/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkotsur%2Faws-lambda-scala/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262222460,"owners_count":23277435,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","cloud","json","scala","serverless"],"created_at":"2025-06-01T19:07:15.373Z","updated_at":"2025-06-27T08:32:04.651Z","avatar_url":"https://github.com/mkotsur.png","language":"Scala","funding_links":["https://ko-fi.com/mkotsur","paypal.me/mkotsur"],"categories":[],"sub_categories":[],"readme":"[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0fb7e6e25c1846e3b54f836bbb65a24b)](https://www.codacy.com/app/miccots/aws-lambda-scala?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=mkotsur/aws-lambda-scala\u0026amp;utm_campaign=Badge_Grade)\n[![Known Vulnerabilities](https://snyk.io/test/github/mkotsur/aws-lambda-scala/badge.svg?targetFile=build.sbt)](https://snyk.io/test/github/mkotsur/aws-lambda-scala?targetFile=build.sbt)\n[![Build Status](https://circleci.com/gh/mkotsur/aws-lambda-scala.svg?\u0026style=shield\u0026circle-token=22c35ff0e9c28f61d483d178f8932c928e47dfc2)](https://circleci.com/gh/mkotsur/aws-lambda-scala)\n[![Maven Central](https://img.shields.io/maven-central/v/io.github.mkotsur/aws-lambda-scala_2.12.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.github.mkotsur%22)\n[![Join the chat at https://gitter.im/software-farm/aws-lambda-scala](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/software-farm/aws-lambda-scala?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nWriting a handler for AWS lambda in Scala can be as easy as...\n\n```scala\nimport io.circe.generic.auto._\nimport io.github.mkotsur.aws.handler.Lambda._\nimport io.github.mkotsur.aws.handler.Lambda\nimport com.amazonaws.services.lambda.runtime.Context\n\ncase class Ping(inputMsg: String)\n\ncase class Pong(outputMsg: String)\n\nclass PingPongHandler extends Lambda[Ping, Pong] {\n\n  override def handle(ping: Ping, context: Context) = Right(Pong(ping.inputMsg.reverse))\n\n}\n```\nThe input JSON will be automatically de-serialized 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. \n\nThis handler can be used in AWS Lambda as: `io.github.mkotsur.example::handle`.\n\nFeatures:\n\n* Return Futures right from the handler!\n* JSON (de)serialization of case classes;\n* Plain strings are supported too;\n* [AWS API Gateway proxy integration](http://docs.aws.amazon.com/apigateway/latest/developerguide/integrating-api-with-aws-services-lambda.html);\n* Uncaught errors are logged with SLF4J and re-thrown.\n\n## Examples\n\n### Returning futures\n\n```scala\nimport io.circe.generic.auto._\nimport io.github.mkotsur.aws.handler.Lambda._\nimport io.github.mkotsur.aws.handler.Lambda\nimport com.amazonaws.services.lambda.runtime.Context\nimport scala.concurrent.Future\n\ncase class Ping(inputMsg: String)\n\nclass PingFuturePongHandler extends Lambda[Ping, Future[Int]] {\n\n  override def handle(ping: Ping, context: Context) = \n    Right(Future.successful(ping.inputMsg.length))\n\n}\n```\n\n### Not receiving and not returning any value\n\nThis lambda will accept an empty string, or string with `null` as an input.\n\n```scala\nimport io.circe.generic.auto._\nimport io.github.mkotsur.aws.handler.Lambda._\nimport io.github.mkotsur.aws.handler.Lambda\nimport com.amazonaws.services.lambda.runtime.Context\n\nclass NothingToNothingHandler extends Lambda[None.type, None.type] {\n  \n  override protected def handle(i: None.type, c: Context) = {\n    println(\"Only side effects\")\n    Right(None)\n  }\n\n}\n```\n\n### API Gateway proxy integration\n\nYou can write less boilerplate when implementing a handler for API Gateway proxy events by extending `Lambda.ApiProxy[I, C, O]`. There are three type parameters there. The first one (`I`) corresponds to the `body` field of the `API Gateway proxy event`, the second one (`C`) corresponds to `requestContext` field, and the third one – to the `body` in the response object. More info about how the even looks like [here](https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html).\n\n```scala\nimport io.circe.generic.auto._\nimport io.circe.Json\nimport io.github.mkotsur.aws.handler.Lambda._\nimport io.github.mkotsur.aws.proxy._\nimport io.github.mkotsur.aws.handler.Lambda\nimport com.amazonaws.services.lambda.runtime.Context\nimport MyProxy._\n\nobject MyProxy {\n\n  case class MyRequestBody(name: String)\n\n  case class MyResponseBody(score: Int)\n\n}\n\nclass MyProxy extends Lambda.ApiProxy[MyRequestBody, Json, MyResponseBody] {\n  override def handle(\n                                 i: ApiProxyRequest[MyRequestBody, Json],\n                                 c: Context\n                               ): Either[Throwable, ApiProxyResponse[MyResponseBody]] =\n    i.body match {\n      case Some(MyRequestBody(\"Bob\")) =\u003e\n        Right(ApiProxyResponse.success(Some(MyResponseBody(100))))\n      case Some(MyRequestBody(\"Alice\")) =\u003e\n        Right(ApiProxyResponse.success(Some(MyResponseBody(50))))\n      case Some(_) =\u003e\n        Right(ApiProxyResponse(404))\n      case None =\u003e\n        Left(new IllegalArgumentException)\n    }\n}\n\n```\n\nTip 1: of course, you can also pass a type defined by a case class into the second type parameter. Please check #24 and `src/test/scala/io/github/mkotsur/aws/proxy/ProxyRequestTest.scala` for an example.\n\nTip 2: Don't forget that `Lambda.ApiProxy` is a very thin wrapper around `Lambda`, so if something in `ApiProxyRequest` or `ApiProxyResponse` doesn't work for you - feel free to define your own case classes (and if you believe that the use case is generic enough – consider contributing back to the library).\n\n### Other usages\n\nFeel free to look at `src/test/scala` for more examples. And of course, contributions to the docs are welcome!\n\n\n## Adding to your project\n\nScala versions supported: 2.11.x, 2.12.x, 2.13.x.\n\n```sbt\nlibraryDependencies += \"io.github.mkotsur\" %% \"aws-lambda-scala\" % {latest-version}\n```\n## How does aws-lambda-scala compare with Serverless framework\nShort answer: they complement each other. Long answer: read [this blog post](https://medium.com/@mkotsur/this-is-why-you-should-consider-using-aws-lambda-scala-6b3ea841f8b0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkotsur%2Faws-lambda-scala","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkotsur%2Faws-lambda-scala","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkotsur%2Faws-lambda-scala/lists"}