Last active
March 23, 2020 14:15
-
-
Save larkintuckerllc/053d6e6d1dc7af7c418d77e054949fd0 to your computer and use it in GitHub Desktop.
AWS
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 boto3 | |
from os import getenv | |
sns = boto3.resource('sns') | |
topic = sns.Topic(getenv('APP_TOPIC_ARN')) | |
def lambda_handler(event, context): | |
for event_record in event["Records"]: | |
if event_record["eventName"] != "INSERT": | |
return { 'statusCode': 200 } | |
identity_id = event_record["dynamodb"]["Keys"]["IdentityId"]["S"] | |
name = event_record["dynamodb"]["NewImage"]["Name"]["S"] | |
topic.publish( | |
Message=name, | |
Subject='Todo Created', | |
MessageAttributes={ | |
'IdentityId': { | |
'DataType': 'String', | |
'StringValue': identity_id, | |
} | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment