0

I have a Spring Cloud Function application with two functions:

@Component
public class MyFunctionOne implements Function<Object, Boolean> {

    @Override
    public Boolean apply(Object o) {
        return true;
    }
}

@Component
public class MyFunctionTwo implements Function<Object, Boolean> {

    @Override
    public Boolean apply(Object o) {
        return true;
    }
}

I have both spring-cloud-starter-function-web and spring-cloud-function-adapter-aws in my project dependencies.

I would like to call both MyFunctionOne and MyFunctionTwo separately.

I can achieve this running locally in two ways. I can do this either calling function directly (since I am using spring-cloud-starter-function-web) by calling localhost:8080/myFunctionOne. Or I can use the Function Routing functionality by calling localhost:8080/functionRouter and supplying myFunctionOne in spring.cloud.function.definition http header. This works fine and I can both trigger MyFunctionOne and MyFunctionTwo separately.

I have deployed the module to AWS Lambda. How do I supply spring.cloud.function.definition dynamically? According to documentation I can use org.springframework.cloud.function.adapter.aws.FunctionInvoker as a AWS Lambda handler. Or, alternatively I can define my own SpringBootStreamHandler. However, it seems that it is not possible to define spring.cloud.function.definition dynamically.

Is there a way to choose a function in Spring Cloud Function deployed to AWS lambda?

Maksim Sorokin
  • 2,334
  • 3
  • 34
  • 61

1 Answers1

1

So, we have a bit of an issue with routing on AWS and it is being fixed as we speak. You can follow this issue - https://github.com/spring-cloud/spring-cloud-function/issues/698.

In any event, we'll have a new release early next week (3.1.3-RELEASE) which will include the fixes, samples and docs to address the issue you're describing

Oleg Zhurakousky
  • 5,820
  • 16
  • 17