Search code examples
aws-lambdaspring-cloudserverlessspring-cloud-awsspring-cloud-function

How to invoke a function running in the cloud with spring


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 ?


Solution

  • The way to do it in 2023 is with a LambdaClient (from aws sdk, not in Spring)

    https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/examples-lambda.html#invoke-function