Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use serverless remove when using existing buckets with s3 events #6905

Open
joshuaduffy opened this issue Oct 30, 2019 · 10 comments
Open

Comments

@joshuaduffy
Copy link

Bug Report

Description

Observed with latest version of serverless 1.55.1

  1. What did you do?
    Ran serverless remove to delete a stack that contains a number of lambdas that are attached an existing bucket (as detailed in https://serverless.com/framework/docs/providers/aws/events/s3/#using-existing-buckets)

  2. What happened?

Stack failed to delete with:

An error occurred: ResourceContentEventCustomS31 - Failed to delete resource. The specified bucket does not exist See details in CloudWatch Log: 2019/10/30/[$LATEST]d80e4ccd09fc4483bf18b9e3c3b63ec3.
  1. What should've happened?

Stack should delete.

  1. What's the content of your serverless.yml file?

Bucket created in resources section...

resources:
  Resources:
    ContentBucket:
      Type: AWS::S3::Bucket

... and referenced with existing=true flag

  thing:
    handler: thing
    package:
      artifact: ./artifacts/thing.zip
    events:
      - s3:
          bucket: ${self:provider.contentBucket}
          events:
            - s3:ObjectCreated:*
          existing: true
@pmuens
Copy link
Contributor

pmuens commented Oct 31, 2019

Hey @joshuaduffy thanks for opening 👍

This happens because you create and remove the bucket with the stack. Apparently the bucket is remove before the event source gets removed, that's why you see the error. You could use a DependsOn clause on your bucket to ensure that it's removed after the event associated is removed.

@joshuaduffy
Copy link
Author

No worries, thank you for the information.

Still experiencing the same issue when I use DependsOn, on the bucket, and reference the lambdas, I shall do some investigations and report back with anything I find.

@nickygb
Copy link

nickygb commented Sep 28, 2020

No worries, thank you for the information.

Still experiencing the same issue when I use DependsOn, on the bucket, and reference the lambdas, I shall do some investigations and report back with anything I find.

@joshuaduffy I'm experiencing the same problem, could you solve it?

@stepan-yudin-clearscale

Facing the same issue. Any workaround?
As of now I manually removing the CF stack

@jdgonzaleza
Copy link

Is there a solution for this issue?? I integrated my project with serverless pro CI/CD and it is failing in the "destruction" job. This job basically runs serverless remove --stage <branch_name> .

@clearcoding
Copy link

Having the same issue.

@rafaeldasilva
Copy link

I have a similar issue. On my case I don't create the bucket in resources section, I just use a pre-existing one on my lambda.
The error message that I get is
Received response status [FAILED] from custom resource. Message returned: No policy is associated with the given resource.

Could it be related with role permissions? I see there is two possible actions related to Event Notifications on S3 service GetBucketNotification and PutBucketNotification.
Should not have a DeleteBucketNotification?

@mtamiola-priv
Copy link

@rafaeldasilva I have the same issue.
I'm not removing whole stack but just lambda which is triggered by existing bucket. The only "workaround" I found it to give lambda full permission to that lambda, then it is removed fine.

@spacewaterbear
Copy link

I had the same issue. I deleted the bucket by hand (and the cloudformation associated but not sure it was needed). Then I re-run the pipeline on gitlab (or whatever) and it worked

@ssignal
Copy link

ssignal commented Mar 15, 2024

I got the same error message. I solve the problem by adding the permission to the lambda for the resource (ex. S3) after removing the lambda in CloudFormation.
The error message means that the lambda has no permission to update or remove a S3 bucket.
So the lambda can not be removed by serverless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests