Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LambdaInvokerFactory and @LambdaFunction do not support multiple environments #602

Closed
codan84 opened this issue Jan 15, 2016 · 2 comments
Closed
Assignees

Comments

@codan84
Copy link
Contributor

codan84 commented Jan 15, 2016

If I create an interface:

interface MyLambdas {
    @LambdaFunction(functionName = "my-aws-lambda-name")
    public String helloWorld(String name);
}

And then build an implementation:

AWSLambdaClient lambda = new AWSLambdaClient(); lambda.configureRegion(Regions.EU_WEST_1);
MyLambdas lambdas = LambdaInvokerFactory.build(MyLambdas.class, lambda);

This is all fine. However, it doesn't support different deployment environments (say int/test/live), where a lambda can have different name (say created via CloudFormation).

To address this, I would propose to overload LambdaInvokerFactory.build to take an additional map of key->lambdaName. Key would store the value passed to @LambdaFunction, whilst value for this key would be the actual function name in AWS. This would allow to use different function names for different environments. An example of use:

interface MyLambdas {
    @LambdaFunction(functionName = "hello-world-lambda-key")
    public String helloWorld(String name);
}

Map<String, String> myLambdaNames = new HashMap<String, String>();
myLambdaNames.put("hello-world-lambda-key", "my-aws-lambda-name");

AWSLambdaClient lambda = new AWSLambdaClient();
lambda.configureRegion(Regions.EU_WEST_1);
MyLambdas lambdas = LambdaInvokerFactory.build(MyLambdas.class, lambda, myLambdaNames);

As you can see this let's us to pull the names at runtime, from places like config etc. I think this would be a beneficial addition to the API.
I have implemented this functionality in this fork

@shorea
Copy link
Contributor

shorea commented Jan 19, 2016

Made some comments in the PR.

@shorea shorea self-assigned this Jan 19, 2016
@shorea shorea closed this as completed Jan 22, 2016
@gigi888
Copy link

gigi888 commented Jun 16, 2016

so cool! it solves our problem too! Many thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants