Consuming the SNS message and sending emails
As the last step, let's create a Lambda function that will subscribe to our topic and send a welcome mail. As usual, let's create our module and the package:
$ mkdir -p lambda-userregistration-welcomemail/src/main/
java/com/serverlessbook/lambda/userregistration/welcomemail
Then, let's add the package into the settings.gradle
file:
echo "include 'lambda-userregistration-welcomemail'" >> settings.gradle
Let's first create the build.gradle
file in our new module and add the required dependencies:
dependencies { compile group: 'com.amazonaws', name: 'aws-lambda-java-events', version: '1.3.0' compile group: 'com.amazonaws', name: 'aws-java-sdk-ses', version: '1.11.+'compile group: 'com.google.inject', name: 'guice', version: guiceVersion }
Then, let's create our Handler
class:
public class Handler implements RequestHandler<SNSEvent, Void> { private static final Injector INJECTOR = Guice.createInjector(); private...