This commit is contained in:
2025-01-04 00:34:03 +01:00
parent 41829408dc
commit 0ca14bbc19
18111 changed files with 1871397 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
export function locationConstraintMiddleware(options) {
return (next) => async (args) => {
const { CreateBucketConfiguration } = args.input;
const region = await options.region();
if (!CreateBucketConfiguration?.LocationConstraint && !CreateBucketConfiguration?.Location) {
args = {
...args,
input: {
...args.input,
CreateBucketConfiguration: region === "us-east-1" ? undefined : { LocationConstraint: region },
},
};
}
return next(args);
};
}
export const locationConstraintMiddlewareOptions = {
step: "initialize",
tags: ["LOCATION_CONSTRAINT", "CREATE_BUCKET_CONFIGURATION"],
name: "locationConstraintMiddleware",
override: true,
};
export const getLocationConstraintPlugin = (config) => ({
applyToStack: (clientStack) => {
clientStack.add(locationConstraintMiddleware(config), locationConstraintMiddlewareOptions);
},
});