During parts 2, 3, and 4, we introduced the concept behind the AWS Serverless Java Container and especially its variant for the Spring Boot (3) application, learned how to develop, deploy, run, and optimize a Spring Boot 3 Application on AWS Lambda using AWS Serverless Java Container. In parts 5, 6, and 7, we did the same but for AWS Lambda Web Adapter. In this part of the series, we'll introduce another alternative, the framework called Spring Cloud Function, concepts behind it, and especially its integration with AWS Lambda.
Spring Cloud Function
Spring Cloud Function is a project with the following high-level goals:
- Promote the implementation of business logic via functions.
- Decouple the development lifecycle of business logic from any specific runtime target so that the same code can run as a web endpoint, a stream processor, or a task. One of these specific runtime targets can be AWS Lambda, which will be the focus of this article.
- Support a uniform programming model across serverless providers, as well as the ability to run standalone (locally or in a PaaS).
- Enable Spring Boot features (auto-configuration, dependency injection, metrics) on serverless providers.
- It abstracts away all of the transport details and infrastructure, allowing the developer to keep all the familiar tools and processes and focus firmly on business logic.
A simple function application (in the context of Spring) is an application that contains beans of type Supplier, Java 8 Function interface, or Consumer.
Spring Cloud Function on AWS Lambda
With Spring Cloud Function on AWS Lambda, AWS adapter takes a Spring Cloud Function app and converts it to a form that can run in AWS Lambda. So, with AWS, it means that a simple function bean should somehow be recognized and executed in the AWS Lambda environment. This fits very well into the AWS Lambda model with Amazon API Gateway in front, which is similar to the Java 8 function that receives the (HTTP) request, executes some business logic, and then sends the (HTTP) response to the caller.
@SpringBootApplication
public class FunctionConfiguration {
public static void main(String[] args) {
SpringApplication.run(FunctionConfiguration.class, args);
}
@Bean
public Function<String, String> uppercase() {
return value -> value.toUpperCase();
}
}
The diagram below describes the request flow in the typical web application on AWS. AWS Request Adapter converts the JSON coming from the Lambda function to the HttpServletRequest, which then invokes the Spring Dispatcher Servlet, which then interacts with our Spring Boot application on the API level without starting a web server (i.e., Tomcat). Then response flows back, and AWS Response Adapter converts HttpServletResponse to JSON, which the Lambda function sends back to API Gateway.
Conclusion
In this part of the series, we introduced Spring Cloud Function and especially its integration with AWS Lambda and the concepts behind it. In the next part, we'll learn how to develop and deploy an application using this framework.
Update from February 20, 2025: new measurements with Spring Boot 3.4 and Spring Cloud Function AWS Adapter version 4.2 published in the article Spring Boot 3.4 application on AWS Lambda- Part 3 Spring Cloud Function AWS.

Top comments (0)