class StackMaster::SnsTopicFinder
Constants
- TopicNotFound
Public Class Methods
new(region)
click to toggle source
# File lib/stack_master/sns_topic_finder.rb, line 5 def initialize(region) @resource = Aws::SNS::Resource.new(region: region) end
Public Instance Methods
find(reference)
click to toggle source
# File lib/stack_master/sns_topic_finder.rb, line 9 def find(reference) raise ArgumentError, 'SNS topic references must be non-empty strings' unless reference.is_a?(String) && !reference.empty? topic = @resource.topics.detect { |t| topic_name_from_arn(t.arn) == reference } raise TopicNotFound, "No topic with name #{reference} found" unless topic topic.arn end
Private Instance Methods
topic_name_from_arn(arn)
click to toggle source
# File lib/stack_master/sns_topic_finder.rb, line 21 def topic_name_from_arn(arn) arn.split(":")[5] end