*Version: 1.0 | Last Updated: 2025-03-13*
## Overview
- **Integration Name:** AWS SNS
- **Purpose:** To integrate AWS with MoovingON AI, enabling users to receive AWS alerts through MoovingON AI.
- **Purpose:** Support team, TAM
- **Prerequisites:**
- A valid AWS account
- MoovingON AI account access with integration permissions
---
## Table of Contents
- [[#Setup Instructions]]
- [[#Configuration]]
- [[#Testing the Integration]]
- [[#Related Links]]
---
## Setup Instructions
1. Step 1: In MoovingON AI, navigate to Settings -> Integrations.

2. Step 2: On the right side of the page, select "Add Webhook."

3. Step 3: Enter an integration name for the webhook and click "Submit."

4. Step 4: A webhook basic authentication (Username and Token) will be created after submission.
****
- Save the generated Username and Token for use in AWS SNS
---
## Configuration
#### 1. Setting the Lambda function push
Need to create a new AWS Lambda python3 function that will translate the SNS message to MoovingON AI, let's name it “PushEvents2MoovingON”
The function code:
import json
import urllib3
import logging
import ast
http = urllib3.PoolManager()
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def lambda_handler(event, context):
# URL for MoonActive Demo test
url = "{ENDPOINT}"
#eventmessage = ast.literal_eval(event['Records'][0]['Sns']['Message'])
#eventmessage = event['Records'][0]['Sns']['Message']
#print(eventmessage)
messagesns = json.loads(event['Records'][0]['Sns']['Message'])
message = {
"service": messagesns['Service'],
"host": messagesns['Host'],
"value": messagesns['Value'],
"severity": "CRITICAL"
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Basic {AUTHKEY}
}
encoded_msg = json.dumps(message).encode('utf-8')
response = http.request('POST', url, body=encoded_msg, headers=headers)
logger.info('Start New Push!!!')
logger.info('Status Code: {}'.format(response.status))
logger.info('Response: {}'.format(response.data))
**NOTE**: The **{AUTHKEY}** should be extracted as in the [[#Setup Instructions]]
****
#### 2. **SNS Topic**
- **Open the SNS Topic and press the Create subscription button**
****
- **Create Subscription**
Choose the Protocol “AWS Lambda”, copy the ARN ID from the Lambda function “PushEvents2MoovingON” into the Endpoint and press the Create subscription button
****
Creating a subscription:
****
You should see a new subscription LAMBDA in the Topic
****
---
## Testing the Integration
To test it, press the button Publish message inside the subscription:
****
For example, we used this message:
{
"default": "Sample fallback message",
"lambda": "{\"Host\":\"TestHost\",\"Service\": \"TestService\",\"Value\":\"TestValue\"}"
}
****
Alert in MoovingON AI:
****
---
## Related Links
- **External Resources:** [AWS Lambda](https://docs.aws.amazon.com/lambda/) , [AWS SNS](https://docs.aws.amazon.com/sns/)