From acb3216626347dfe75ed5fde8e585270fe80f103 Mon Sep 17 00:00:00 2001 From: Robert Cambridge Date: Wed, 13 Oct 2021 14:26:31 +0200 Subject: [PATCH] fix bug where S3 client would not get instantiated with offline options --- README.md | 4 +++- index.js | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 03729d1..bff8832 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,8 @@ custom: # ... ``` -run `sls offline start --profile s3local` to sync to the local s3 bucket instead of Amazon AWS S3 +As per [serverless-s3-local's instructions](https://github.com/ar90n/serverless-s3-local#triggering-aws-events-offline), once a local credentials profile is configured, run `sls offline start --aws-profile s3local` to sync to the local s3 bucket instead of Amazon AWS S3 + +> `bucketNameKey` will not work in offline mode and can only be used in conjunction with valid AWS credentials, use `bucketName` instead. run `sls deploy` for normal deployment \ No newline at end of file diff --git a/index.js b/index.js index 380300c..6eba8b6 100644 --- a/index.js +++ b/index.js @@ -96,10 +96,7 @@ class ServerlessS3Sync { s3Options.endpoint = new provider.sdk.Endpoint(this.serverless.service.custom.s3Sync.endpoint); s3Options.s3ForcePathStyle = true; } - const s3Client = new provider.sdk.S3({ - region: region, - credentials: awsCredentials - }); + const s3Client = new provider.sdk.S3(s3Options); if(this.getEndpoint() && this.isOffline()) { //see: https://github.com/aws/aws-sdk-js/issues/1157 s3Client.shouldDisableBodySigning = () => true