Documentation Center
AlienVault® USM Anywhere™

Setting Up an SNS Topic and a Lambda Function

When using Amazon SNS, you create a topic and control access to it by defining policies that determine which publishers and subscribers can communicate with the topic. As a publisher, USM Anywhere can then send messages (notifications) to topics for which it has the needed credentials (access key).

When an SNS topic has a Lambda function subscribed to it, it invokes the Lambda function with the payload of a published message. The Lambda function receives the message as an input parameter and can manipulate the information in the message, publish the message to other SNS topics, and/or send the message to other AWS services or endpoints.

To set up a SNS topic and a Lambda Function for USM Anywhere notifications

  1. Log in to your AWS Account and go to the Amazon SNS console.
  2. Create a new SNS topic in the AWS SNS dashboard page.

    • Click Create topic.
    • Enter a topic name and a display name.
    • Click Create topic.
  3. Open the AWS Lambda page and click Create a function.
  4. Click Author from scratch.
  5. Click the dotted square icon and select SNS in the list.
  6. Select the SNS topic you created.
  7. Select the Enable trigger option.
  8. Click Next.
  9. Create a hello world lambda function:

    • Enter a name and a description.
    • Select Python 2.7 in the Runtime field.
    • In the Lambda function code, copy and paste the following code:

      import json def lambda_handler(event, context): message = json.loads(event['Records'][0]['Sns']['Message']) print("JSON: " + json.dumps(message)) return message

    • Add an example "Hello World" Lambda function for the SNS topic

    • In the Lambda function handler and role select a handler, a role, and an existing role.

      Set the role and timeout settings for handling USM Anywhere notifications

    • Expand the Advanced settings and set the Timeout to 10 seconds.
    • Click Create Function.