{"id":20256189,"url":"https://github.com/getmarkus/spring-integration-lambda-proxy","last_synced_at":"2026-05-12T19:36:39.563Z","repository":{"id":208000065,"uuid":"93341335","full_name":"getmarkus/spring-integration-lambda-proxy","owner":"getmarkus","description":"Integrates Spring Integration and AWS Lambda proxy handlers","archived":false,"fork":false,"pushed_at":"2017-06-05T04:29:45.000Z","size":57,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-10T18:33:41.744Z","etag":null,"topics":["aws-lambda","spring-boot","spring-integration"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/getmarkus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-06-04T21:04:05.000Z","updated_at":"2017-06-05T03:58:35.000Z","dependencies_parsed_at":"2023-11-19T01:47:17.539Z","dependency_job_id":null,"html_url":"https://github.com/getmarkus/spring-integration-lambda-proxy","commit_stats":null,"previous_names":["getmarkus/spring-integration-lambda-proxy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/getmarkus/spring-integration-lambda-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getmarkus%2Fspring-integration-lambda-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getmarkus%2Fspring-integration-lambda-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getmarkus%2Fspring-integration-lambda-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getmarkus%2Fspring-integration-lambda-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/getmarkus","download_url":"https://codeload.github.com/getmarkus/spring-integration-lambda-proxy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getmarkus%2Fspring-integration-lambda-proxy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32954595,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T09:19:52.626Z","status":"ssl_error","status_checked_at":"2026-05-12T09:17:33.438Z","response_time":102,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","spring-boot","spring-integration"],"created_at":"2024-11-14T10:45:42.869Z","updated_at":"2026-05-12T19:36:39.542Z","avatar_url":"https://github.com/getmarkus.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spring-integration-lambda-proxy\n\nThere are several projects connecting the last mile between the AWS API Gateway and AWS Lambda.  In the summer of 2016, the only available integration was a one-to-one mapping of an API Gateway Resource and a Lambda Function.  There were ways to make it a somewhat efficient developer work flow.  However, it produced annoying friction.\n\nLast November 2016, AWS introduced the 'Proxy' interface.  This interface allows the API Gateway to proxy several resource endpoints to a single Lambda function. However, this mostly just pushed the issue down the road. This is because you need to now have an efficient way to distribute the requests to your code within that single Lambda Function.\n\nOne such interesting project aiming to reduce that friction is the [AWS Serverless Container](https://github.com/awslabs/aws-serverless-java-container). It attempts to seamlessly connect your Lambda Proxy entry point to your code. It has interfaces for Spring, Jersey and Spark. It and other projects like it pass the Lambda Proxy request to a servlet/dispatcher front controller.\n\nHowever, when I tried to do anything real or bring in other Spring projects, the constraints often got in the way and soon became counter productive. Also, it seemed like these projects were trying to enforce the wrong concern.  AWS Lambda feels much more event-driven and has a distinct message passing scheme. Rather than a request-response MVC front controller.\n\nSo in this project, I tried to solve the issue by implementing message routing via [Spring Integration](https://projects.spring.io/spring-integration/).  Additionally, you can run your code locally via Spring Boot.\n\nA key to make Spring Boot play nice with Lambda is to tell it not to run a full web environment:\n\n```java\npublic ServerlessOutput handleRequest(ServerlessInput serverlessInput, Context context) {\n\n    if(!initialized) {\n\n        applicationContext = new SpringApplicationBuilder(LambdaConfig.class)\n            .web(false) //tells Spring not to setup a servlet and listen on port\n            .run(new String[]{});\n\n        initialized = true;\n\n    }\n```\n\nAfter wrapping the Lambda request body in a Spring Integration Message envelope, then one option to route is to set a header. You can use whatever scheme makes sense for you.\n\n```java\nMessage\u003cString\u003e message = MessageBuilder.withPayload(serverlessInput.getBody())\n    .setHeader(\"route\", (serverlessInput.getHttpMethod()\n                            + serverlessInput.getPath().replace('/', '-'))\n    .build();\n\n```\n\nFour key parts of Spring Integration are needed:\n\n1. Messaging Gateway\n```java\n@MessagingGateway\n\npublic interface ControllerGateway {\n\n    @Gateway(requestChannel=\"requestChannel\")\n    public Message\u003c?\u003e route(Message\u003cString\u003e message);\n\n}\n```\n2. Integration Flow to, typically, route to a deserializer\n```java\n@Bean\n\npublic IntegrationFlow requestFlow(){\n\n    return IntegrationFlows.from(\"requestChannel\")\n                            .route(new HeaderValueRouter(\"route\"))\n                            .get();\n\n}\n```\n3. Integration Flow to route to a Controller or Resource\n```java\n@Bean\n\npublic IntegrationFlow greeIntegrationFlow(){\n\n    return IntegrationFlows.from(\"POST-greeting\")\n                            .transform(Transformers.fromJson(GreetingMessage.class))\n                            .channel(\"POST-greeting-activator\")\n                            .get();\n\n}\n```\n4. Service Activator triggering your logic\n```java\npublic class GreetingController {\n\n    @RequestMapping(method = RequestMethod.POST, produces=\"application/json\")\n    @ServiceActivator(inputChannel=\"POST-greeting-activator\")\n    public GreetingMessage reply(@RequestBody GreetingMessage greeting) {\n\n        greeting.setMessage(\"Well...hello there\");\n\n        return greeting;\n\n    }\n}\n```\n\nThis is a simple happy path and you are likely to need more complicated (and potentially automatic) routing schemes.  But Spring Integration provides the building blocks.\n\nAreas for improvement:\n- Cold startup time with Spring (way too slow, but probably tunable)\n- Need a seamless way to automatically recognize resource de-serialization\n\n## Installation\n\n```console\nmvn clean package\n```\n\n## Usage\n\nTo run locally:\n```console\nmvn spring-boot:run\n\ncurl -d \"{ \\\"message\\\":\\\"hi\\\" }\" -H \"Content-Type:application/json\" -X POST http://localhost:8080/greeting\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetmarkus%2Fspring-integration-lambda-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgetmarkus%2Fspring-integration-lambda-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetmarkus%2Fspring-integration-lambda-proxy/lists"}