AWS SNS Ruby SDK Cannot Sign Application Endpoint

The Ruby SDK is a little confusing as the docs have two subscription methods. One of them is outdated, now I believe here .

Class: AWS :: SNS :: Client

Another is the intended method, as it says in the source code: # To create a subscription, use the {Topic#subscribe} method.

But in the code it points to, those passed in the parameters go through a filtering process that prevents me from specifying the protocol application

.

def endpoint_opts (endpoint, opts = {})

    case
    when endpoint.is_a?(SQS::Queue)

      # auto add a policy to the queue to allow the topic
      # to send the queue messages
      unless opts[:update_policy] == false
        policy = endpoint.policy || SQS::Policy.new
        policy.allow(
          :principal => :any,
          :actions => [:send_message],
          :resources => [endpoint]
        ).where(:source_arn).is(arn)
        endpoint.policy = policy
      end

      { :protocol => 'sqs', :endpoint => endpoint.arn }

    when endpoint =~ /^arn:/

      ################################################# 
      THIS IS WHAT FILTERS IT, I get this error
      ################################################# 
      raise ArgumentError, "expected a queue ARN" unless
        endpoint =~ /^arn:aws(.*?):sqs:/
      { :protocol => "sqs", :endpoint => endpoint }
    when endpoint.kind_of?(URI)
      { :protocol => endpoint.scheme,
        :endpoint => endpoint.to_s }
    when endpoint =~ /^(https?):/
      { :protocol => $1, :endpoint => endpoint }
    when endpoint.include?("@")
      { :protocol => opts[:json] ? "email-json" : "email",
        :endpoint => endpoint }
    when endpoint.gsub(/\D/,'') =~ /\d{11,15}/
      { :protocol => "sms", :endpoint => endpoint.gsub(/\D/,'') }
    else
      raise ArgumentError, "could not determine protocol for '#{endpoint}'"
    end
  end

      

and the documentation does not specify a way to do it either as it lists all the protocols other than the application.

So ... It looks like the protocol option application

is being filtered on purpose, or someone is not writing very good tests :) Is there a way to use the AWS SDK to subscribe endpoints from a topic app? Am I missing something big here? Please, help!

+3


source to share





All Articles