File tree 2 files changed +7
-5
lines changed
packages/middleware-location-constraint/src
2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ describe("locationConstrainMiddleware", () => {
9
9
10
10
it ( "should remove any CreateBucketConfiguration from requests directed at us-east-1" , async ( ) => {
11
11
const handler = locationConstraintMiddleware ( {
12
- region : "us-east-1"
12
+ region : ( ) => Promise . resolve ( "us-east-1" )
13
13
} ) ( next , { } as any ) ;
14
14
const input = {
15
15
CreateBucketConfiguration : { LocationConstraint : "us-east-1" } ,
@@ -28,7 +28,7 @@ describe("locationConstrainMiddleware", () => {
28
28
29
29
it ( "should apply a CreateBucketConfiguration with a LocationConstraint of the target region for requests directed outside of us-east-1" , async ( ) => {
30
30
const handler = locationConstraintMiddleware ( {
31
- region : "us-east-2"
31
+ region : ( ) => Promise . resolve ( "us-east-2" )
32
32
} ) ( next , { } as any ) ;
33
33
const input = {
34
34
foo : "bar"
@@ -47,7 +47,7 @@ describe("locationConstrainMiddleware", () => {
47
47
48
48
it ( "should do nothing if a LocationConstraint had already been set on a request directed outside of us-east-1" , async ( ) => {
49
49
const handler = locationConstraintMiddleware ( {
50
- region : "us-east-2"
50
+ region : ( ) => Promise . resolve ( "us-east-2" )
51
51
} ) ( next , { } as any ) ;
52
52
const input = {
53
53
CreateBucketConfiguration : { LocationConstraint : "us-east-1" } ,
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ export function locationConstraintMiddleware(
24
24
args : InitializeHandlerArguments < any >
25
25
) : Promise < InitializeHandlerOutput < Output > > => {
26
26
const { CreateBucketConfiguration } = args . input ;
27
+ //After region config resolution, region is a Provider<string>
28
+ const region = await options . region ( ) ;
27
29
if (
28
30
! CreateBucketConfiguration ||
29
31
! CreateBucketConfiguration . LocationConstraint
@@ -32,10 +34,10 @@ export function locationConstraintMiddleware(
32
34
...args ,
33
35
input : {
34
36
...args . input ,
35
- CreateBucketConfiguration : { LocationConstraint : options . region }
37
+ CreateBucketConfiguration : { LocationConstraint : region }
36
38
}
37
39
} ;
38
- } else if ( options . region === "us-east-1" ) {
40
+ } else if ( region === "us-east-1" ) {
39
41
args = {
40
42
...args ,
41
43
input : {
You can’t perform that action at this time.
0 commit comments