class AWS::SNS::Topic

def publish default_message, options = {}

Returns:
  • (String) - Returns the ID of the message that was sent.

Options Hash: (**options)
  • :sqs (String) -- - Message to use when sending to an
  • :email_json (String) -- - Message to use when sending
  • :email (String) -- - Message to use when sending to an
  • :https (String) -- - Message to use when sending to an
  • :http (String) -- - Message to use when sending to an
  • :subject (String) -- Used as the "Subject" line when

Parameters:
  • options (Hash) --
  • default_message (String) -- The message you want to send to the
def publish default_message, options = {}
  message = { :default => default_message }
  [:http, :https, :email, :email_json, :sqs].each do |protocol|
    if options[protocol]
      message[protocol.to_s.gsub(/_/, '-')] = options[protocol]
    end
  end
  publish_opts = {}
  publish_opts[:message] = message.to_json
  publish_opts[:message_structure] = 'json'
  publish_opts[:subject] = options[:subject] if options[:subject]
  publish_opts[:topic_arn] = arn
  
  response = client.publish(publish_opts)
  response[:message_id]
end