{"id":17274478,"url":"https://github.com/idugalic/serverless-company","last_synced_at":"2025-07-30T05:34:46.392Z","repository":{"id":113631479,"uuid":"87293241","full_name":"idugalic/serverless-company","owner":"idugalic","description":"Serverless. FaaS. Spring Boot. Spring Cloud Function","archived":false,"fork":false,"pushed_at":"2020-07-10T11:34:35.000Z","size":1451,"stargazers_count":16,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T08:57:26.700Z","etag":null,"topics":["aws-lambda","faas","java","openwhisk","serverless","spring"],"latest_commit_sha":null,"homepage":"http://idugalic.github.io/serverless-company","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idugalic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2017-04-05T09:47:01.000Z","updated_at":"2023-09-08T17:23:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"0f0dc47c-c539-4dc4-995a-628257a63402","html_url":"https://github.com/idugalic/serverless-company","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/idugalic/serverless-company","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idugalic%2Fserverless-company","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idugalic%2Fserverless-company/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idugalic%2Fserverless-company/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idugalic%2Fserverless-company/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idugalic","download_url":"https://codeload.github.com/idugalic/serverless-company/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idugalic%2Fserverless-company/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267815189,"owners_count":24148356,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","faas","java","openwhisk","serverless","spring"],"created_at":"2024-10-15T08:54:00.987Z","updated_at":"2025-07-30T05:34:46.380Z","avatar_url":"https://github.com/idugalic.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [projects](http://idugalic.github.io/projects)/serverless-company ![Java CI with Maven](https://github.com/idugalic/serverless-company/workflows/Java%20CI%20with%20Maven/badge.svg?branch=master) [![GitPitch](https://gitpitch.com/assets/badge.svg)](https://gitpitch.com/idugalic/serverless-company/master?grs=github\u0026t=white)\n\n## Table of Contents\n\n   * [FaaS in private clouds](#faas-in-private-clouds)\n   * [Spring Cloud Function](#spring-cloud-function)\n   * [Building and Running a Function](#building-and-running-a-function)\n      * [Locally](#locally)\n      * [AWS Lambda](#aws-lambda)\n         * [AWS web console](#aws-web-console)\n         * [AWS CLI](#aws-cli)\n      * [Apache Openwhisk](#apache-openwhisk)\n         * [Install Openwhisk](#install-openwhisk)\n         * [Build docker images via maven](#build-docker-images-via-maven)\n         * [Create and invoke a function](#create-and-invoke-a-function)\n   * [Slides](#slides)\n     * [References and further reading](#references-and-further-reading)\n\n\n\nThis project is intended to demonstrate best practices for building a serverless web application with help of [Spring Cloud Function project](https://github.com/markfisher/spring-cloud-function). \n\nServerless architectures refer to applications that significantly depend on third-party services (knows as Backend as a Service or \"BaaS\") or on custom code that's run in ephemeral containers (Function as a Service or \"FaaS\"). We will focus on FaaS.\n\nThe best known vendor host is currently [AWS Lambda](https://aws.amazon.com/lambda/).\n\nImportant attributes of serverless are:\n\n - No management of server hosts or processes\n - Self auto provision \u0026 auto-scale based on load\n - Costs based on actual, precise, usage\n \n## FaaS in private clouds\n\nFaaS in private clouds is not quite ready yet. Existing projects need to mature, a lot of considerations still need to be worked.\nExisting projects out there are:\n\n- IBM’s [OpenWhisk incubating project at the ASF](https://github.com/openwhisk/openwhisk), \n- [Kubeless](https://github.com/kubeless/kubeless), \n- [Funktion from Fabric8](https://github.com/funktionio/funktion), \n- [Fission from Platform9](https://github.com/fission/fission), \n- [GalacticFog](http://www.galacticfog.com), \n- [IronFunctions](https://github.com/iron-io/functions), \n- [FAAS-for-docker](https://github.com/alexellis/faas)...\n\n## [Spring Cloud Function](https://github.com/markfisher/spring-cloud-function)\n\nSpring Cloud Function provides a new programming model for Spring Boot applications, abstracting 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. It helps you create decoupled functions for serverless hosting providers (like AWS Lambda) or any other runtime target without vendor lock-in.\n\nSpring Cloud Function is a project with the following high-level goals:\n\n- Promote the implementation of business logic via functions.\n\n- 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.\n\n- Support a uniform programming model across serverless providers, as well as the ability to run standalone (locally or in a PaaS).\n\n- Enable Spring Boot features (auto-configuration, dependency injection, metrics) on serverless providers.\n\n\nThe @Beans can be Function, Consumer or Supplier (all from java.util), and their parametric types can be String or POJO. A Function is exposed as an HTTP POST if spring-cloud-function-web is on the classpath, and as a Spring Cloud Stream Processor if spring-cloud-function-stream is on the classpath and a spring.cloud.function.stream.endpoint property is configured in the Spring environment. A Consumer is also exposed as an HTTP POST, or as a Stream Sink. A Supplier translates to an HTTP GET, or a Stream Source.\n\n\n## Building and Running a Function\n\n```\n$ cd serverless-company\n$ mvn clean install\n```\n\n### [Locally (Standalone)](https://github.com/idugalic/serverless-company/tree/master/serverless-company-functions)\n\nTo deploy the Uppercase function as a REST endpoint only requires adding the “spring-cloud-function-web” dependency in your pom file.\n\nYou are ready now to run your function as a spring boot application:\n\n```\n$ cd serverless-company/serverless-company-functions\n$ mvn spring-boot:run\n```\n```\n$ curl -H \"Content-Type: text/plain\" localhost:8080/uppercaseFunction -d '{\"input\":\"Hello\"}'\n```\n\nExpected result would be:\n```\n{\"result\":\"HELLO\"}\n```\n### [AWS Lambda](https://github.com/idugalic/serverless-company/tree/master/serverless-company-aws)\n\n[AWS Lambda](http://docs.aws.amazon.com/lambda/latest/dg/welcome.html) is a compute service that lets you run code without provisioning or managing servers. AWS Lambda executes your code only when needed and scales automatically, from a few requests per day to thousands per second. You pay only for the compute time you consume\n\nThis module uses an [adapter layer for a Spring Cloud Function application onto AWS Lambda](https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-aws) - spring-cloud-function-adapter-aws.\n\nThe AWS Adapter has a couple of different request handlers you can use like SpringBootRequestHandler, SpringBootStreamHandler, FunctionInvokingS3EventHandler, and so on. If you check the source code of SpringBootRequestHandler, you will see that it instead implements AWS's RequestHandler for us and also propagates the request to our function. The only reason we need to implement it is to specify the type of the input and the output parameters of the function, so AWS can serialize/deserialize them for us.\n\nBuild and package from the command line:\n\n```\n$ cd serverless-company/serverless-company-aws\n$ ./mvnw clean package\n```\n\n\n#### AWS web console\n\nAfter a successful build and package, if you navigate to the target directory, you will see two JARs, including one ending with -aws\n\nLet's fire up the [AWS Console](https://aws.amazon.com/console/) and navigate to the Lambda service's page. Click on \"Create a Lambda function\" and select \"Blank Function.\" We don't need any trigger for the function because it will be triggered by API Gateway and we will setup that later on so for now just click on \"Next.\"\n\nOn the next page, you need to give a name for your function. I simply gave it \"uppercase-function\" but you can use anything else. But you need to remember it because it will be required for the setup of API Gateway. For the runtime set \"Java 8.\" Drop the JAR ending with -aws on the upload button. Continue with the configuration:\n\n- Handler: com.idugalic.handler.UppercaseFunctionHandler\n- Role: uppercase-role\n- Runtime: Java 8\n- Advanced-\u003eMemory(MB): 320\n- Advanced-\u003eTimeout: 1 min\t\n\nInput test:\n```\n{\n  \"input\": \"test\"\n}\n```\nRun test:\n```\n{\n  \"result\": \"TEST\"\n}\n```\n\n\n#### AWS CLI\n\n- Install AWS CLI: http://docs.aws.amazon.com/cli/latest/userguide/awscli-install-bundle.html\n- Create the function:\n```\n$ aws lambda create-function --function-name uppercase-sample --role arn:aws:iam::[USERID]:role/service-role/[ROLE] --zip-file fileb://serverless-company/serverless-company-aws/target/serverless-company-aws-1.0.0.BUILD-SNAPSHOT-aws.jar --handler com.idugalic.handler.UppercaseFunctionHandler --description \"Spring Cloud Function AWS Adapter Example\" --runtime java8 --region eu-central-1 --timeout 30 --memory-size 1024 --publish\n```\n\n### [Apache Openwhisk](https://github.com/idugalic/serverless-company/tree/master/serverless-company-openwhisk)\n\n[Apache OpenWhisk](http://openwhisk.incubator.apache.org/) is a serverless event-based programming service and an Apache Incubator project.\nThere is a public instance of Openwhisk hosted and run by [IBM Bluemix](https://www.ibm.com/cloud-computing/bluemix/openwhisk).\nFor the purposes of this lab we will install it locally.\n\nThis module uses an [adapter layer for a Spring Cloud Function application onto Openwhisk](https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk) - spring-cloud-function-adapter-openwhisk.\n\n\n#### Install Openwhisk\n\nDownload and install VirtualBox and Vagrant for your operating system and architecture.\n\nFollow these step to run your first OpenWhisk Action:\n\n```\n# Clone openwhisk\n$ git clone --depth=1 https://github.com/apache/incubator-openwhisk.git openwhisk\n\n# Change directory to tools/vagrant\n$ cd openwhisk/tools/vagrant\n\n# Run script to create vm and run hello action\n$ ./hello\n```\n\n#### Build docker images via maven (optional)\n\nRequires username and password of docker hub repository (so you can push an image). Please note that image is already publicly available here https://hub.docker.com/r/idugalic/serverless-company-openwhisk/ , and you do not need to create an image localy.\n\n```\n$ cd serverless-company\n$ mvn clean install\n$ DOCKER_HOST=unix:///var/run/docker.sock mvn docker:build -DpushImage\n```\n\n#### Create and invoke a function\n```\n$ vagrant ssh\n$ wsk action create example --docker idugalic/serverless-company-openwhisk\n$ wsk action invoke example --result --param uppercaseRequest '{\"input\":\"foo\"}'\n```\n\n## Slides\n\nhttps://gitpitch.com/idugalic/serverless-company/master?grs=github\u0026t=white\n\n## References and further reading\n\n- [Evolution of Business Logic from Monoliths through Microservices, to Functions](https://read.acloud.guru/evolution-of-business-logic-from-monoliths-through-microservices-to-functions-ff464b95a44d)\n- [Deploy your microservice (Amazon Web Services S3, API Gateway and Lambda)](https://www.youtube.com/watch?list=PLVe-2wcL84b8c09AKImmAISiEI6vPefON\u0026v=6ZzGx79Nz4o)\n- http://docs.aws.amazon.com/lambda/latest/dg/welcome.html\n- https://github.com/kbastani/event-stream-processing-microservices\n- http://openwhisk.org/\n- https://github.com/krook\n- [Functions as a Service (FaaS) with Docker swarm](http://blog.alexellis.io/functions-as-a-service)\n- https://medium.com/@pfernandom/serverless-for-private-clouds-or-managing-the-server-for-a-serverless-app-f9321e45a910\n- https://www.ibm.com/blogs/bluemix/2017/02/microservices-multi-compute-approach-using-cloud-foundry-openwhisk/\n- https://github.com/anaibol/awesome-serverless\n- https://github.com/lambci/docker-lambda\n- https://github.com/fission/fission\n- https://speakerdeck.com/dsyer/spring-cloud-function\n- https://github.com/markfisher/spring-cloud-function\n- https://dzone.com/articles/run-code-with-spring-cloud-function-on-aws-lambda\n- https://github.com/apache/incubator-openwhisk\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidugalic%2Fserverless-company","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidugalic%2Fserverless-company","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidugalic%2Fserverless-company/lists"}