Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix create bucket method using v3 way #645

Merged
merged 1 commit into from
Dec 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions serverless-s3-local/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,13 @@ class ServerlessS3Local {
return Promise.resolve([]);
}

const { CreateBucketCommand } = require("@aws-sdk/client-s3")
const s3Client = this.getClient();
return Promise.all(
buckets.map((Bucket) => {
this.serverless.cli.log(`creating bucket: ${Bucket}`);
return s3Client.createBucket({ Bucket }).promise();
const command = new CreateBucketCommand({ Bucket });
return s3Client.send(command);
})
).catch(() => ({}));
}
Expand All @@ -347,14 +349,14 @@ class ServerlessS3Local {
}

getClient() {
const { S3 } = require("@aws-sdk/client-s3");
return new S3({
s3ForcePathStyle: true,
endpoint: new AWS.Endpoint(
`http://${this.options.host}:${this.options.port}`
),
accessKeyId: this.options.accessKeyId,
secretAccessKey: this.options.secretAccessKey,
const { S3Client } = require("@aws-sdk/client-s3");
return new S3Client({
forcePathStyle: true,
endpoint: `http://${this.options.host}:${this.options.port}`,
credentials: {
accessKeyId: this.options.accessKeyId,
secretAccessKey: this.options.secretAccessKey,
},
});
}

Expand Down