SNS Manager

View Licence Agreement

class sosw.components.sns.SnsManager(**kwargs)[source]

AWS Simple Notification System Manager helper. Requires the Role to have permissions to access SSM for requested resources, something like.

Must have a recipient specified either during initialization or later using set_recipient method. Messages received by send_message() are batched and will be actually send to SNS only during the call of commit() or during the destruction of the class.

The method doesn’t yet support batching messages for multiple recipients, so in case you try to change the recipient it automatically sends all the currently batched messages to the previous recipient.


Combines messages from self.queue and pushes them to self.recipient. Cleans the queue after that.

create_subscription(topic_arn, protocol, endpoint)[source]

Create a subscription to the topic

  • topic_arn (str) – ARN of a topic
  • protocol (str) – The type of endpoint to subscribe
  • endpoint (str) – Endpoint that can receive notifications from Amazon SNS

Create a new topic name

Parameters:topic_name (str) – New topic name to create
Returns:New topic ARN
Return type:str
send_message(message, subject=None, forse_commit=False)[source]

If the subject is not yet set (for example during __init__() of the class) - then require subject to be set. Otherwize we accept None subject and simply append messages to queue. Once the subject changes - the queue is commite automatically.

  • message (str) – Message to be send in body of SNS message. Queued.
  • subject (str) – Optional. Custom subject for message.
set_client_attr(name, value)[source]

Sets the given _name_ attribute to _value_. Commits the self.queue if there are any messages in it.


Set custom separator for messages from the queue