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
5 changes: 5 additions & 0 deletions .changes/next-release/feature-s3util-4a5bd10b.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "feature",
"category": "s3util",
"description": "Add allowFipsEndpoint option in validateArnRegion"
}
19 changes: 14 additions & 5 deletions lib/services/s3util.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,16 @@ var s3util = {
/**
* Validate region field in ARN supplied in Bucket parameter is a valid region
*/
validateArnRegion: function validateArnRegion(req) {
validateArnRegion: function validateArnRegion(req, options) {
if (options === undefined) {
options = {};
}

var useArnRegion = s3util.loadUseArnRegionConfig(req);
var regionFromArn = req._parsedArn.region;
var clientRegion = req.service.config.region;
var useFipsEndpoint = req.service.config.useFipsEndpoint;
var allowFipsEndpoint = options.allowFipsEndpoint || false;

if (!regionFromArn) {
throw AWS.util.error(new Error(), {
Expand All @@ -145,16 +150,20 @@ var s3util = {
});
}

if (
useFipsEndpoint ||
regionFromArn.indexOf('fips') >= 0
) {
if (useFipsEndpoint && !allowFipsEndpoint) {
throw AWS.util.error(new Error(), {
code: 'InvalidConfiguration',
message: 'ARN endpoint is not compatible with FIPS region'
});
}

if (regionFromArn.indexOf('fips') >= 0) {
throw AWS.util.error(new Error(), {
code: 'InvalidConfiguration',
message: 'FIPS region not allowed in ARN'
});
}

if (!useArnRegion && regionFromArn !== clientRegion) {
throw AWS.util.error(new Error(), {
code: 'InvalidConfiguration',
Expand Down