micronaut-projects / micronaut-aws

Projects specific to integrating Micronaut and Amazon Web Services (AWS)
Apache License 2.0
85 stars 79 forks source link

MicronautRequestStreamHandler ignores function name configuration property #264

Open bsamartins opened 4 years ago

bsamartins commented 4 years ago

When running function in SAM with MicronautRequestStreamHandler, micronaut.function.name is ignored by the handler.

MicronautRequestStreamHandler takes, by default, the function name from the Lambda context. Because function name is populated it never evaluates the configuration property, not allowing the name to be overriden.

besctar commented 3 years ago

Even more. Right now AWS Console does not allow Lambda Environment variable to have dots in it's name. (only letters, numbers, underscore). So, in order to define function name in lambda config we need another property name (e.g. micronautFunctionName or functionName).

besctar commented 3 years ago

Workaround working for me:

public class CustomMicronautRequestStreamHandler extends MicronautRequestStreamHandler {
    @Override
    protected String resolveFunctionName(Environment env) {
        return env.getProperty("functionName", String.class, (String) null);
    }
}
bsamartins commented 3 years ago

Even more. Right now AWS Console does not allow Lambda Environment variable to have dots in it's name. (only letters, numbers, underscore). So, in order to define function name in lambda config we need another property name (e.g. micronautFunctionName or functionName).

You should be able to use MICRONAUT_FUNCTION_NAME.