Last active
October 31, 2017 17:18
-
-
Save mgdombrowski/342e5110a44210f20db892a60b646762 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import json | |
import boto3 | |
snsClient = boto3.client('sns') | |
print('Loading function') | |
def lambda_handler(event, context): | |
for record in event['Records']: | |
# Kinesis data is base64 encoded so decode here | |
# payload = json.loads(base64.b64decode(record['kinesis']['data'])) | |
payload = base64.b64decode(record['kinesis']['data']) | |
print payload | |
response = snsClient.publish( | |
TopicArn='arn:aws:sns:us-east-1:964214137428:heartanomalies', | |
Message='A possible heart anomaly was detected. Are you ok?' + payload + '\nClick here to let us know:\n http://heartnotification.com', | |
Subject='Anomaly detected', | |
MessageStructure='string', | |
MessageAttributes={ | |
'String': { | |
'DataType': 'String', | |
'StringValue': 'New records have been processed.' | |
} | |
} | |
) | |
return 'Successfully processed {} records.'.format(len(event['Records'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment