Skip to content

Commit a236609

Browse files
committed
fix(middleware-sdk-s3-control): do not validate for FIPS in S3 Outposts
1 parent 179afb9 commit a236609

File tree

2 files changed

+17
-37
lines changed

2 files changed

+17
-37
lines changed

packages/middleware-sdk-s3-control/src/process-arnables-plugin/parse-outpost-arnables.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ const validateOutpostsArn = (
120120
clientRegion,
121121
clientSigningRegion: signingRegion,
122122
useFipsEndpoint,
123+
allowFipsRegion: true,
123124
});
124125
validateNoDualstack(useDualstackEndpoint);
125126
};

packages/middleware-sdk-s3-control/src/process-arnables-plugin/plugin.spec.ts

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ describe("getProcessArnablesMiddleware", () => {
169169
expect(context).toMatchObject({ signing_service: "s3-outposts", signing_region: "us-gov-east-1" });
170170
});
171171

172-
it("should validate when arn region is fips region", async () => {
173-
expect.assertions(1);
172+
it("should compute hostname for fips region", async () => {
173+
expect.assertions(4);
174174
const clientRegion = "us-gov-east-1";
175175
const hostname = `s3-control.${clientRegion}.amazonaws.com`;
176176
const options = setupPluginOptions({
@@ -181,36 +181,14 @@ describe("getProcessArnablesMiddleware", () => {
181181
});
182182
const stack = getStack(hostname, options);
183183
const handler = stack.resolve((() => {}) as any, {});
184-
try {
185-
await handler({
186-
input: {
187-
Name: "arn:aws-us-gov:s3-outposts:fips-us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
188-
},
189-
});
190-
} catch (e) {
191-
expect(e.message).toContain("FIPS region is not supported");
192-
}
193-
});
194-
195-
it("should update endpoint, headers and context correctly if client is fips region", async () => {
196-
expect.assertions(4);
197-
const clientRegion = "fip-us-gov-east-1";
198-
const hostname = `s3-control.${clientRegion}.amazonaws.com`;
199-
const options = setupPluginOptions({
200-
region: clientRegion,
201-
useArnRegion: true,
202-
regionInfoProvider: () => Promise.resolve({ hostname, partition: "aws-us-gov" }),
203-
});
204-
const stack = getStack(hostname, options);
205-
const handler = stack.resolve((() => {}) as any, {});
206184
const {
207185
output: { request, context, input },
208186
} = (await handler({
209187
input: {
210188
Name: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint",
211189
},
212190
})) as any;
213-
expect(request.hostname).toBe("s3-outposts.us-gov-east-1.amazonaws.com");
191+
expect(request.hostname).toBe("s3-outposts-fips.us-gov-east-1.amazonaws.com");
214192
expect(request.headers).toMatchObject({ "x-amz-outpost-id": "op-01234567890123456" });
215193
expect(input.AccountId).toBe("123456789012");
216194
expect(context).toMatchObject({ signing_service: "s3-outposts", signing_region: "us-gov-east-1" });
@@ -391,8 +369,8 @@ describe("getProcessArnablesMiddleware", () => {
391369
expect(context).toMatchObject({ signing_service: "s3-outposts", signing_region: "us-gov-east-1" });
392370
});
393371

394-
it("should validate when arn region is fips region", async () => {
395-
expect.assertions(1);
372+
it("should compute hostname for fips region", async () => {
373+
expect.assertions(4);
396374
const clientRegion = "us-gov-east-1";
397375
const hostname = `s3-control.${clientRegion}.amazonaws.com`;
398376
const options = setupPluginOptions({
@@ -403,16 +381,17 @@ describe("getProcessArnablesMiddleware", () => {
403381
});
404382
const stack = getStack(hostname, options);
405383
const handler = stack.resolve((() => {}) as any, {});
406-
try {
407-
await handler({
408-
input: {
409-
Bucket:
410-
"arn:aws-us-gov:s3-outposts:fips-us-gov-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
411-
},
412-
});
413-
} catch (e) {
414-
expect(e.message).toContain("FIPS region is not supported");
415-
}
384+
const {
385+
output: { request, context, input },
386+
} = (await handler({
387+
input: {
388+
Bucket: "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:bucket:mybucket",
389+
},
390+
})) as any;
391+
expect(request.hostname).toBe("s3-outposts-fips.us-gov-east-1.amazonaws.com");
392+
expect(request.headers).toMatchObject({ "x-amz-outpost-id": "op-01234567890123456" });
393+
expect(input.AccountId).toBe("123456789012");
394+
expect(context).toMatchObject({ signing_service: "s3-outposts", signing_region: "us-gov-east-1" });
416395
});
417396

418397
it("should update endpoint, headers and context correctly if client is fips region", async () => {

0 commit comments

Comments
 (0)