Skip to content

Commit ca137bb

Browse files
author
Chase Coalwell
committed
fix: resolve region
1 parent e08b134 commit ca137bb

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

packages/middleware-location-constraint/src/index.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("locationConstrainMiddleware", () => {
99

1010
it("should remove any CreateBucketConfiguration from requests directed at us-east-1", async () => {
1111
const handler = locationConstraintMiddleware({
12-
region: "us-east-1"
12+
region: () => Promise.resolve("us-east-1")
1313
})(next, {} as any);
1414
const input = {
1515
CreateBucketConfiguration: { LocationConstraint: "us-east-1" },
@@ -28,7 +28,7 @@ describe("locationConstrainMiddleware", () => {
2828

2929
it("should apply a CreateBucketConfiguration with a LocationConstraint of the target region for requests directed outside of us-east-1", async () => {
3030
const handler = locationConstraintMiddleware({
31-
region: "us-east-2"
31+
region: () => Promise.resolve("us-east-2")
3232
})(next, {} as any);
3333
const input = {
3434
foo: "bar"
@@ -47,7 +47,7 @@ describe("locationConstrainMiddleware", () => {
4747

4848
it("should do nothing if a LocationConstraint had already been set on a request directed outside of us-east-1", async () => {
4949
const handler = locationConstraintMiddleware({
50-
region: "us-east-2"
50+
region: () => Promise.resolve("us-east-2")
5151
})(next, {} as any);
5252
const input = {
5353
CreateBucketConfiguration: { LocationConstraint: "us-east-1" },

packages/middleware-location-constraint/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export function locationConstraintMiddleware(
2424
args: InitializeHandlerArguments<any>
2525
): Promise<InitializeHandlerOutput<Output>> => {
2626
const { CreateBucketConfiguration } = args.input;
27+
const region = await options.region();
2728
if (
2829
!CreateBucketConfiguration ||
2930
!CreateBucketConfiguration.LocationConstraint
@@ -32,10 +33,10 @@ export function locationConstraintMiddleware(
3233
...args,
3334
input: {
3435
...args.input,
35-
CreateBucketConfiguration: { LocationConstraint: options.region }
36+
CreateBucketConfiguration: { LocationConstraint: region }
3637
}
3738
};
38-
} else if (options.region === "us-east-1") {
39+
} else if (region === "us-east-1") {
3940
args = {
4041
...args,
4142
input: {

0 commit comments

Comments
 (0)