Attach function to an existing 3s bucket

Hello, I have the following serverless.yaml

service: abc-audit

provider:
  name: aws
  runtime: nodejs8.10
  memorySize: 128
  timeout: 120
  environment:
    DELIVERY_STREAM_NAME: ${file(./config.js):${opt:stage}.DELIVERY_STREAM_NAME}
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        "s3:*"
      Resource:
        Fn::Join:
          - ""
          - - "arn:aws:s3:::*"
plugins:
  serverless-plugin-existing-s3

functions:
  abc:
    handler: index.handler
    events:
      - s3:
          bucket: ${file(./config.js):${opt:stage}.BUCKET}
          event: s3:ObjectCreated:*
          rules:
            - suffix: .gz

when I deploy the function, I get the following error:

Serverless: Operation failed!

  Serverless Error ---------------------------------------

  An error occurred: S3BucketMbmlogslampstackprod - mbm-logs-lamp-stack-prod already exists.

I am using https://github.com/matt-filion/serverless-external-s3-event plugging
What am I missing?

1 Like

Any update?

I have also been suffering from the issue with serverless-plugin-existing-s3 plug-in.

You need to use existingS3 as the event name instead of s3. If you don’t then Serverless will attempt to create the S3 bucket for you.

Hi @buggy. Hope you’re doing well. I need to to use existingS3 in order to use a Lambda function that triggers file uploads to the bucket. I tried to use it based on what you suggested; however I am getting the following error when trying to get the logs of my lambda:

Please let me know if you know what that error means.

image

@Daniela I haven’t used that plugin in a long time :frowning:

Ok, thanks. Hopefully I’ll find the solution and when I do, I’ll definetely update this… I kind of really need to find the solution so will work even harder on it

1 Like

HI Daniela,
I am trying to do the same thing. Did you find a solution?
Thanks,
Prem

You now have the ability to import your resources https://aws.amazon.com/blogs/aws/new-import-existing-resources-into-a-cloudformation-stack/ into your existing serverless stack, I have not tried it