Skip to content

Support VPC Endpoint SQS Queue URL #2156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 7, 2019
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
------------------

* Issue - Support VPC Endpoint pattern in Aws::SQS::Plugins::QueueUrl (Github #2114)

1.23.0 (2019-10-23)
------------------

Expand Down
12 changes: 11 additions & 1 deletion gems/aws-sdk-sqs/lib/aws-sdk-sqs/plugins/queue_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def update_endpoint(context, url)
# region, then we will modify the request to have
# a sigv4 signer for the proper region.
def update_region(context, queue_url)
if queue_region = queue_url.to_s.split('.')[1]
if queue_region = parse_region(queue_url)
if queue_region != context.config.region
config = context.config.dup
config.region = queue_region
Expand All @@ -33,6 +33,16 @@ def update_region(context, queue_url)
end
end

private

# take the first component after service delimiter
# https://sqs.us-east-1.amazonaws.com/1234567890/demo
# https://vpce-x-y.sqs.us-east-1.vpce.amazonaws.com/1234567890/demo
def parse_region(url)
parts = url.split('sqs.')
parts[1].split('.').first if parts.size > 1
end

end

handler(Handler)
Expand Down
9 changes: 9 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 @@ -45,6 +45,15 @@ module SQS
expect(resp.context.http_request.headers['authorization']).to include('cn-north-1')
end

it 'supports vpc endpoint queue URL' do
url = "https://vpce-xxxx-yyyy.sqs.us-east-1.vpce."\
"amazonaws.com/1234567890/demo"
client = Client.new(stub_responses:true, region: 'cn-north-1')
resp = client.send(method, params.merge(queue_url: url))
expect(resp.context.http_request.headers['authorization'])
.to include('us-east-1')
end

it 'raises an error for a badly formatted queue url' do
expect {
client = Client.new(stub_responses:true)
Expand Down