I really like the AWS lambdas call approach from Java described in this blog post .
However, if I have 3 environments (int / test / live), and each of them has a slightly different name for the lambda (created through cloudformation), I cannot think of a way to have one interface and call the lambda with a different name depending on the environment Wednesday.
I use Spring, and therefore, if I could do something like:
@Component
interface MyLambdas {
@Value("${name}")
String name;
@LambdaFunction(name = name)
String callMyLambda(String stuff);
}
service = LambdaInvokerFactory.build(MyLambdas.class, lambda);
But obviously I can’t do this on the interface, it won’t bean! Is there any way to do this? I feel like I hit a brick wall ...
Now I call lambda the "old way":
String readLambdaName = "My_Lambda";
ObjectMapper objectMapper = new ObjectMapper();
AWSLambdaClient lambda = new AWSLambdaClient();
lambda.configureRegion(Regions.EU_WEST_1);
String json = objectMapper.writeValueAsString(request);
InvokeRequest req = new InvokeRequest()
.withFunctionName(readLambdaName)
.withPayload(json);
InvokeResult res = lambda.invoke(req);
int result = objectMapper.readTree(res.getPayload().array()).asInt();
, . , ...
, , aws-sdk github. , - SDK...