AWS Lambda

This module supports the AWS Lambda server-less architecture.

Dependency

<dependency>
    <groupId>org.seedstack.addons.aws</groupId>
    <artifactId>aws-lambda</artifactId>
</dependency>
Show version
dependencies {
    compile("org.seedstack.addons.aws:aws-lambda:1.0.0")
}

Usage

The add-on uses on the interface-based approach of AWS Lambda. To declare a SeedStack-enabled request handler, extend the BaseRequestHandler class:

public class SomeRequestHandler extends BaseRequestHandler<String, String> {
    @Inject
    @Named("en")
    private Greeter greeter;

    @Override
    public String handleRequest(String input, Context context) {
        return greeter.greet(input);
    }
}

The BaseRequestHandler class will initialize SeedStack on the first call of the lambda function. Your lambda can then be injected like any SeedStack class. Interception is not supported on the request handler itself but can be used on all other classes.

Initialization is only performed during a lambda cold start but it is recommended to keep your lambda code focused and small so the initialization time is kept to a minimum.

All sources of events are supported.

Packaging

Packaging should be done according to the AWS lambda packaging rules, that is using the Maven shade plugin instead of normal SeedStack capsule:

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.3</version>
        <configuration>
          <createDependencyReducedPom>false</createDependencyReducedPom>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>  
   

On this page


Edit this page