1

Does Spring offer some abstraction to invoke an arbitrary cloud function (for example and AWS lambda function) ?

It seems to me this could be the job of spring-cloud-function, but it looks (maybe I'm mistaken) as if this project concentrates more on abstracting the creation of functions that run on serverless environments, rather than on how to invoke those functions from other java code (for example a microservice).

I also checked out spring-cloud-aws but found no sign of lambda in the documentation.

Of course I could write the code to invoke functions quite easily as described here but being in the habit of Spring abstracting quite literally everything, I feel like I'm missing something when writing code that calls directly the aws java SDK.

Did I miss a documentation/sample somewhere ?

Sébastien Nussbaumer
  • 6,202
  • 5
  • 40
  • 58

1 Answers1

0

The answer is a resounding YES ;)

Have you checked SCF AWS support. You can also check out the 4 examples we have here - https://github.com/spring-cloud/spring-cloud-function/tree/main/spring-cloud-function-samples

You can also check out our presentation from SpringOne this year - https://springone.io/2021/sessions/spring-cloud-function. Although it packs 3 different topics, I touch a little bit on AWS at my opening and then Mark (from AWS) follows me for the next 20 min. The sample code for our demo with instructions is here

Oleg Zhurakousky
  • 5,820
  • 16
  • 17
  • That's really interesting, I'm not familiar with springboot/java since I work as a DevOps, so basically how springboot invokes another function? using the AWS API or a trigger? I tried to see the examples but I didn't get it. – Juan Fontes Oct 13 '21 at 06:41
  • Hum I didn't get it too ... it seems to me you provided links to how to develop a lambda function with spring. I just need to invoke a lambda function with spring. Starting with the samples, this would mean the uppercase function is already developed and deployed as a lambda by a totally different team than mine, and it may even be in another technology than java, there is no spring cloud stream. Now I need to call that lambda from my spring boot application which is not a lambda (for example a command line application running on my machine). Which sample shows how to do that ? – Sébastien Nussbaumer Oct 13 '21 at 10:27
  • Well, if such function is deployed and you want to just invoke it isn't the job of exposing such lambda to the outside world is the job of API Gateway? And if so Spring REST, MVC etc will do the job. Am I missing something in your question? – Oleg Zhurakousky Oct 13 '21 at 15:59
  • Well if my microservice is running on aws too the lambda does not have to be exposed with API Gateway. You can just invoke it as indicated in the link I gave in the question. It's really not complicated but I thought maybe Spring would offer some kind of abstraction for that too (a bit like when using Amazon S3 : I do not use the amazon sdk directly : I have just some config and use Resources starting with "s3://" and everything works out of the box ). – Sébastien Nussbaumer Oct 26 '21 at 06:55
  • But again, using LambdaInvokerFactory is not complicated ... I was juste thinking having a nice abstraction for invoking aws lambda/google function/azure function could be nice – Sébastien Nussbaumer Oct 26 '21 at 06:56