k1LoW / serverless-s3-sync

A plugin to sync local directories and S3 prefixes for Serverless Framework :zap:
182 stars 68 forks source link

fix bug where S3 client would not get instantiated with offline options #93

Closed rcambrj closed 2 years ago

rcambrj commented 2 years ago

It seems as though the s3Options object was intended for use in instantiating provider.sdk.S3, but was never actually used for this...

This affected the usage of serverless-s3-sync in offline mode, because the endpoint would not be respected and the sync process would attempt to talk to AWS. When using credentials configured for S3RVER (serverless-s3-local), running sls offline start results this error:

InvalidAccessKeyId: The AWS Access Key Id you provided does not exist in our records.

Isolating the network results in this error:

UnknownEndpoint: Inaccessible host: `my-bucket-name.s3.eu-central-1.amazonaws.com' at port `undefined'. This service may not be available in the `eu-central-1' region.

...confirming my suspicion.

In addition, the bucketNameKey logic will not work correctly under these circumstances, because it attempts to do the same thing to find the bucketName, so I added something to the README about that; and fixed the parameter name for the AWS credentials profile.

k1LoW commented 2 years ago

@rcambrj Thank you !!!