Skip to content

Commit f7d5875

Browse files
authored
Support VPC Endpoint SQS Queue URL (#2156)
* support VPC Endpoint SQS Queue URL * typo fix [ci skip]
1 parent ef79b1d commit f7d5875

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

gems/aws-sdk-sqs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Unreleased Changes
22
------------------
33

4+
* Issue - Support VPC Endpoint pattern in Aws::SQS::Plugins::QueueUrl (Github #2114)
5+
46
1.23.0 (2019-10-23)
57
------------------
68

gems/aws-sdk-sqs/lib/aws-sdk-sqs/plugins/queue_urls.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def update_endpoint(context, url)
2222
# region, then we will modify the request to have
2323
# a sigv4 signer for the proper region.
2424
def update_region(context, queue_url)
25-
if queue_region = queue_url.to_s.split('.')[1]
25+
if queue_region = parse_region(queue_url)
2626
if queue_region != context.config.region
2727
config = context.config.dup
2828
config.region = queue_region
@@ -33,6 +33,16 @@ def update_region(context, queue_url)
3333
end
3434
end
3535

36+
private
37+
38+
# take the first component after service delimiter
39+
# https://sqs.us-east-1.amazonaws.com/1234567890/demo
40+
# https://vpce-x-y.sqs.us-east-1.vpce.amazonaws.com/1234567890/demo
41+
def parse_region(url)
42+
parts = url.split('sqs.')
43+
parts[1].split('.').first if parts.size > 1
44+
end
45+
3646
end
3747

3848
handler(Handler)

gems/aws-sdk-sqs/spec/client/queue_urls_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ module SQS
4545
expect(resp.context.http_request.headers['authorization']).to include('cn-north-1')
4646
end
4747

48+
it 'supports vpc endpoint queue URL' do
49+
url = "https://vpce-xxxx-yyyy.sqs.us-east-1.vpce."\
50+
"amazonaws.com/1234567890/demo"
51+
client = Client.new(stub_responses:true, region: 'cn-north-1')
52+
resp = client.send(method, params.merge(queue_url: url))
53+
expect(resp.context.http_request.headers['authorization'])
54+
.to include('us-east-1')
55+
end
56+
4857
it 'raises an error for a badly formatted queue url' do
4958
expect {
5059
client = Client.new(stub_responses:true)

0 commit comments

Comments
 (0)