AWS Lambda Configuration with Java CDK

To fetch an environment variable in an AWS Lambda use the stock method System.getenv:

public class Greetings{
    static String message = System.getenv("message");

    public String onEvent(Map<String, String> input) {
        System.out.println("configured: " + message);
        return message;

All environment variables are set with the environment method in the function's Builder:

Function createUserListenerFunction(String functionName,String functionHandler, int memory, int timeout) {
    return Function.Builder.create(this, functionName)
            .environment(Map.of("message","hello, duke"))

The code above is an excerpt from the following screencast:

The project template used in this screencast is available from:


Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments