import json
import boto3


def main(event, context):
    print(event)
    record = event['Records'][0]
    body = record["body"]
    body = body.replace('\n', '')
    body = json.loads(body)
    query = body["body-json"]
    
    message = "Id: " + str(query["id"]) + " - Stock: " + str(query["stock"])
    subject = "BSMSapp"

    client = boto3.client("sns")
    topic_arn = "arn:aws:sns:us-east-1:025685231147:" + query["username"]
    client.publish(TopicArn=topic_arn, Message=message, Subject=subject)
