import os import boto3 def send_message_to_sqs(sqs, message, queue_name): queue = sqs.get_queue_by_name(QueueName=queue_name) queue.send_message(MessageBody=message) def get_sqs_resource(): if os.getenv('SQS_ENDPOINT'): return boto3.resource('sqs', endpoint_url=os.getenv('SQS_ENDPOINT'), region_name=os.getenv("AWS_REGION")) return boto3.resource('sqs') def get_sns_resource(): if os.getenv('SNS_ENDPOINT'): return boto3.resource('sns', endpoint_url=os.getenv('SNS_ENDPOINT'), region_name=os.getenv("AWS_REGION")) return boto3.resource('sns') def publish_message(sns, message): topic_arn = os.getenv('SNS_ARN') topic = sns.Topic(topic_arn) publish = topic.publish(Message=message)