ar90n / serverless-s3-local

Serverless s3 local plugin.
MIT License
215 stars 70 forks source link

AWS is not defined #581

Open peebles opened 2 years ago

peebles commented 2 years ago

In version 0.6.22, I am getting:

ReferenceError: AWS is not defined at ServerlessS3Local.getClient (/Users/peebles/cortina/ca-portal/node_modules/serverless-s3-local/index.js:353:21) at ServerlessS3Local.createBuckets (/Users/peebles/cortina/ca-portal/node_modules/serverless-s3-local/index.js:325:27) ...

And indeed, in index.js line 353 there is a reference to AWS that was never defined:

  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,
    });
  }

Or am I missing something here?

0.6.20 works without error.

filipemacedo commented 1 year ago

Where do you import AWS?

See an example:

import { S3, Endpoint } from "aws-sdk";