Skip to content

Instantly share code, notes, and snippets.

@larkintuckerllc
Last active March 23, 2020 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larkintuckerllc/053d6e6d1dc7af7c418d77e054949fd0 to your computer and use it in GitHub Desktop.
Save larkintuckerllc/053d6e6d1dc7af7c418d77e054949fd0 to your computer and use it in GitHub Desktop.
AWS
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