import boto3 from garcon import task @task.decorate() def sns_publish_message(activity, topic, message, subject=None): """Send sns messages to specific topic w/subject & message Assumes AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY are set as env vars Args: activity (ActivityWorker): The swf activity worker. topic (str): Topic ARN (ex.arn:aws:sns:us-east-1:103233932089:dev_test) message (str): The message you want to send to the topic. Messages must be UTF-8 encoded strings and be at most 4KB in size. subject (str): Optional parameter to be used as the "Subject" line of the email notifications. """ sns = boto3.client('sns') sns.publish(TopicArn=topic, Message=message, Subject=subject)