ar90n / serverless-s3-local

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

Double bucket creation #97

Open HuEric opened 4 years ago

HuEric commented 4 years ago

When starting serverless, I noticed that serverless-s3-local try to create bucket two times.

Serverless: starting handler
Serverless: S3 local started ( port:5645, family: IPv4, address: 127.0.0.1 )
Serverless: creating bucket: s3-storage-dev
error: Error creating bucket. Bucket "s3-storage-dev" already exists
info: PUT /s3-storage-dev 409 12ms -
offline: Starting Offline: dev/eu-west-1.
offline: Offline [http for lambda] listening on http://localhost:3002

serverless.yml

[...]
plugins:
  - serverless-offline
  - serverless-s3-local
[...]
custom:
  serverless-offline:
    httpPort: 3006
  s3: # Local S3
    host: localhost
    port: 5645
  additionalStacks:
    s3: ${file(.cloudformation/s3.yml)}
[...]

.cloudformation/s3.yml

Resources:
  StorageBucket:
    Type: AWS::S3::Bucket
    DeletionPolicy: ${self:custom.deletionPolicy.${self:provider.stage}, self:custom.deletionPolicy.other}
    Properties:
      BucketName: s3-storage-${self:provider.stage}
      AccessControl: Private

My guess is when configuring S3rver in index.js l.221 with configureBuckets, which describes all buckets configuration, also it creates them. Then creating them again in the run function triggers the error index.js l.232.

ar90n commented 4 years ago

Hi @HuEric Thanks for your contribution! I agree with what you said. I fixed this issue by referencing your comment. Please try the latest version (v0.6.3) via npm.