Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gems/aws-sdk-sqs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Unreleased Changes
------------------

* Feature - Support disabling queue url region detection through `disable_queue_url_region_detection`.

1.110.0 (2026-01-16)
------------------

Expand Down
3 changes: 3 additions & 0 deletions gems/aws-sdk-sqs/lib/aws-sdk-sqs/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ class Client < Seahorse::Client::Base
# @option options [Boolean] :disable_host_prefix_injection (false)
# When `true`, the SDK will not prepend the modeled host prefix to the endpoint.
#
# @option options [Boolean] :disable_queue_url_region_detection (false)
# When set to `true`, the region will not be extracted from a provided queue url. Defaults to `false`.
#
# @option options [Boolean] :disable_request_compression (false)
# When set to 'true' the request body will not be compressed
# for supported operations.
Expand Down
15 changes: 15 additions & 0 deletions gems/aws-sdk-sqs/lib/aws-sdk-sqs/plugins/queue_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ module SQS
module Plugins
# @api private
class QueueUrls < Seahorse::Client::Plugin
# When set to `true`, the signing region will not be modified if the configured
# region does not match the region extracted from a provided queue url.
#
# When set to 'false', the signing region will be modified to use the region
# extracted from a provided queue url if it differs from the configured region.
option(
:disable_queue_url_region_detection,
default: false,
doc_type: 'Boolean',
docstring: <<~DOCS)
When set to `true`, the region will not be extracted from a provided queue url. Defaults to `false`.
DOCS

# Extract region from a provided queue_url
class Handler < Seahorse::Client::Handler
def call(context)
Expand All @@ -22,6 +35,8 @@ def update_endpoint(context, url)
# If the region in the queue url is not the configured
# region, then we will modify signing to use it
def update_region(context, queue_url)
return if context.config.disable_queue_url_region_detection

if (queue_region = parse_region(queue_url)) &&
queue_region != context.config.region
context[:auth_scheme]['signingRegion'] = queue_region
Expand Down
1 change: 1 addition & 0 deletions gems/aws-sdk-sqs/sig/client.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module Aws
?correct_clock_skew: bool,
?defaults_mode: String,
?disable_host_prefix_injection: bool,
?disable_queue_url_region_detection: bool,
?disable_request_compression: bool,
?endpoint: String,
?endpoint_cache_max_entries: Integer,
Expand Down
1 change: 1 addition & 0 deletions gems/aws-sdk-sqs/sig/resource.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module Aws
?correct_clock_skew: bool,
?defaults_mode: String,
?disable_host_prefix_injection: bool,
?disable_queue_url_region_detection: bool,
?disable_request_compression: bool,
?endpoint: String,
?endpoint_cache_max_entries: Integer,
Expand Down
26 changes: 26 additions & 0 deletions gems/aws-sdk-sqs/spec/client/queue_urls_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,32 @@ module SQS
expect(resp.context.http_request.headers['authorization'])
.to include('us-west-2')
end

it 'disables region detection when disable_queue_url_region_detection is true' do
url = 'https://sqs.us-west-2.amazonaws.com/1234567890/demo'
client = Client.new(
stub_responses: true,
region: 'us-east-1',
disable_queue_url_region_detection: true
)
resp = client.send(method, params.merge(queue_url: url))
expect(resp.context.http_request.headers['authorization'])
.to include('us-east-1')
expect(resp.context.http_request.headers['authorization'])
.not_to include('us-west-2')
end

it 'uses configured region for custom endpoints when detection disabled' do
url = 'https://sqs.elb-proxy.elb-gamma.us-east-1.amazonaws.com/1234567890/demo'
client = Client.new(
stub_responses: true,
region: 'us-east-1',
disable_queue_url_region_detection: true
)
resp = client.send(method, params.merge(queue_url: url))
expect(resp.context.http_request.headers['authorization'])
.to include('us-east-1')
end
end
end
end
Expand Down