Skip to content

Commit a2e71ca

Browse files
authored
fix(s3): bugfixing the s3 endpoint parser (#3650)
* fix: allow s3 to make requests to s3 object lambda when passed into the arn
1 parent 13d3852 commit a2e71ca

File tree

7 files changed

+31
-12
lines changed

7 files changed

+31
-12
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "bugfix",
3+
"category": "s3",
4+
"description": "Bugfixing the s3 arn endpoint parser"
5+
}

lib/services/s3.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ AWS.util.update(AWS.S3.prototype, {
341341
var accessPointArn = req.service._parsedArn;
342342

343343
var isOutpostArn = accessPointArn.service === 's3-outposts';
344+
var isObjectLambdaArn = accessPointArn.service === 's3-object-lambda';
344345

345346
var outpostsSuffix = isOutpostArn ? '.' + accessPointArn.outpostId: '';
346347
var serviceName = isOutpostArn ? 's3-outposts': 's3-accesspoint';
@@ -356,8 +357,19 @@ AWS.util.update(AWS.S3.prototype, {
356357
useArnRegion ? accessPointArn.region : req.service.config.region,
357358
dnsSuffix
358359
].join('.');
359-
endpoint.host = endpoint.hostname;
360360

361+
if (isObjectLambdaArn) {
362+
// should be in the format: "accesspoint/${accesspointName}"
363+
var serviceName = 's3-object-lambda';
364+
var accesspointName = accessPointArn.resource.split('/')[1];
365+
endpoint.hostname = [
366+
accesspointName + '-' + accessPointArn.accountId,
367+
serviceName,
368+
useArnRegion ? accessPointArn.region : req.service.config.region,
369+
dnsSuffix
370+
].join('.');
371+
}
372+
endpoint.host = endpoint.hostname;
361373
var encodedArn = AWS.util.uriEscape(req.params.Bucket);
362374
var path = req.httpRequest.path;
363375
//remove the Bucket value from path

lib/services/s3util.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ var s3util = {
1818
validateArnService: function validateArnService(req) {
1919
var parsedArn = req.service._parsedArn;
2020

21-
if (parsedArn.service !== 's3' && parsedArn.service !== 's3-outposts') {
21+
if (parsedArn.service !== 's3'
22+
&& parsedArn.service !== 's3-outposts'
23+
&& parsedArn.service !== 's3-object-lambda') {
2224
throw AWS.util.error(new Error(), {
2325
code: 'InvalidARN',
24-
message: 'expect \'s3\' or \'s3-outposts\' in ARN service component'
26+
message: 'expect \'s3\' or \'s3-outposts\' or \'s3-object-lambda\' in ARN service component'
2527
});
2628
}
2729
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,4 @@
146146
"helper-test": "mocha scripts/lib/test-helper.spec.js",
147147
"csm-functional-test": "mocha test/publisher/functional_test"
148148
}
149-
}
149+
}

scripts/region-checker/allowlist.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ var allowlist = {
3737
248,
3838
261,
3939
267,
40-
630,
41-
632,
42-
751,
43-
762,
40+
642,
41+
644,
4442
763,
45-
764,
46-
769
43+
774,
44+
775,
45+
776,
46+
781
4747
]
4848
};
4949

test/services/s3.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3487,7 +3487,7 @@ describe('AWS.S3', function() {
34873487
request.send(function(err, data) {
34883488
expect(err).to.exist;
34893489
expect(err.name).to.equal('InvalidARN');
3490-
expect(err.message).to.equal('expect \'s3\' or \'s3-outposts\' in ARN service component');
3490+
expect(err.message).to.equal('expect \'s3\' or \'s3-outposts\' or \'s3-object-lambda\' in ARN service component');
34913491
done();
34923492
});
34933493
});

test/services/s3control.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ describe('AWS.S3Control', function() {
139139
request.send(function(err, data) {
140140
expect(err).to.exist;
141141
expect(err.name).to.equal('InvalidARN');
142-
expect(err.message).to.equal('expect \'s3\' or \'s3-outposts\' in ARN service component');
142+
expect(err.message).to.equal('expect \'s3\' or \'s3-outposts\' or \'s3-object-lambda\' in ARN service component');
143143
done();
144144
});
145145
});

0 commit comments

Comments
 (0)