module Cumulus::SNS

Public Class Methods

get_aws(name) click to toggle source

Public: Static method that will get an SNS topic from AWS by its name

name - the name of the topic to get

Returns the Aws::SNS::Types::Topic

# File lib/sns/SNS.rb, line 15
def get_aws(name)
  topics.fetch(name)
rescue KeyError
  puts "No SNS topic named #{name}"
  exit
end
topics() click to toggle source

Public: Provide a mapping of topics to their names. Lazily loads resources.

Returns the topics mapped to their names

# File lib/sns/SNS.rb, line 26
def topics
  @topics ||= init_topics
end

Private Class Methods

init_topics() click to toggle source

Internal: Load the topics and map them to their names

Returns the topics mapped to their names

# File lib/sns/SNS.rb, line 35
def init_topics
  Hash[@@client.list_topics.topics.map { |t| [t.topic_arn[(t.topic_arn.rindex(":") + 1)..-1], t.topic_arn] }]
end