class Aws::SQS::Plugins::QueueUrls::Handler
Extract region from a provided queue_url
def call(context)
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
def parse_region(url)
Will not return for:
https://vpce-x-y.sqs.us-east-1.vpce.amazonaws.com/1234567890/demo
https://sqs.us-east-1.amazonaws.com/1234567890/demo
Will return us-east-1 for:
take the first component after the SQS service component
def parse_region(url) parts = URI.parse(url).host.split('.') parts.each_with_index do |part, index| if part == 'sqs' # assume region is the part right after the 'sqs' part return parts[index + 1] end end nil # no region found end
def update_endpoint(context, url)
def update_endpoint(context, url) context.http_request.endpoint = url end
def update_region(context, queue_url)
If the region in the queue url is not the configured
def update_region(context, queue_url) if (queue_region = parse_region(queue_url)) && queue_region != context.config.region context[:auth_scheme]['signingRegion'] = queue_region end end