Skip to content

Commit e929589

Browse files
authored
chore(s3util): add allowFipsEndpoint option in validateArnRegion (#3962)
1 parent 8724023 commit e929589

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "feature",
3+
"category": "s3util",
4+
"description": "Add allowFipsEndpoint option in validateArnRegion"
5+
}

lib/services/s3util.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,16 @@ var s3util = {
132132
/**
133133
* Validate region field in ARN supplied in Bucket parameter is a valid region
134134
*/
135-
validateArnRegion: function validateArnRegion(req) {
135+
validateArnRegion: function validateArnRegion(req, options) {
136+
if (options === undefined) {
137+
options = {};
138+
}
139+
136140
var useArnRegion = s3util.loadUseArnRegionConfig(req);
137141
var regionFromArn = req._parsedArn.region;
138142
var clientRegion = req.service.config.region;
139143
var useFipsEndpoint = req.service.config.useFipsEndpoint;
144+
var allowFipsEndpoint = options.allowFipsEndpoint || false;
140145

141146
if (!regionFromArn) {
142147
throw AWS.util.error(new Error(), {
@@ -145,16 +150,20 @@ var s3util = {
145150
});
146151
}
147152

148-
if (
149-
useFipsEndpoint ||
150-
regionFromArn.indexOf('fips') >= 0
151-
) {
153+
if (useFipsEndpoint && !allowFipsEndpoint) {
152154
throw AWS.util.error(new Error(), {
153155
code: 'InvalidConfiguration',
154156
message: 'ARN endpoint is not compatible with FIPS region'
155157
});
156158
}
157159

160+
if (regionFromArn.indexOf('fips') >= 0) {
161+
throw AWS.util.error(new Error(), {
162+
code: 'InvalidConfiguration',
163+
message: 'FIPS region not allowed in ARN'
164+
});
165+
}
166+
158167
if (!useArnRegion && regionFromArn !== clientRegion) {
159168
throw AWS.util.error(new Error(), {
160169
code: 'InvalidConfiguration',

0 commit comments

Comments
 (0)