class Aws::SQS::Plugins::QueueUrls::Handler

Public Instance Methods

call(context) click to toggle source
# File lib/aws-sdk-sqs/plugins/queue_urls.rb, line 11
def call(context)
  if queue_url = context.params[:queue_url]
    update_endpoint(context, queue_url)
    update_region(context, queue_url)
  end
  @handler.call(context)
end
update_endpoint(context, url) click to toggle source
# File lib/aws-sdk-sqs/plugins/queue_urls.rb, line 19
def update_endpoint(context, url)
  context.http_request.endpoint = url
end
update_region(context, queue_url) click to toggle source

If the region in the queue url is not the configured region, then we will modify the request to have a sigv4 signer for the proper region.

# File lib/aws-sdk-sqs/plugins/queue_urls.rb, line 26
def update_region(context, queue_url)
  if queue_region = parse_region(queue_url)
    if queue_region != context.config.region
      config = context.config.dup
      config.region = queue_region
      config.sigv4_region = queue_region
      config.sigv4_signer = Aws::Plugins::SignatureV4.build_signer(config)
      context.config = config
    end
  end
end

Private Instance Methods

parse_region(url) click to toggle source

take the first component after service delimiter sqs.us-east-1.amazonaws.com/1234567890/demo vpce-x-y.sqs.us-east-1.vpce.amazonaws.com/1234567890/demo

# File lib/aws-sdk-sqs/plugins/queue_urls.rb, line 43
def parse_region(url)
  parts = url.split('sqs.')
  parts[1].split('.').first if parts.size > 1
end