Open RodneyMarable opened 5 years ago
@ajinabraham I know it's 2 years after, but for what is worth, I have reimplemented this plugin due to lack of response from maintainer and included a fix for your issue here as well. If the bucket does not exist, you get the following:
serverless-s3-cleaner: my-bucket not found or you do not have permissions, skipping...
Note the message is not 100% accurate because headBucket API call returns 403 if you do not have permissions to the bucket (even if the bucket does not exist). So I did not bother to do it more detailed due to the risk of being misleading.
If I try to delete a stack with a non-existent bucket present in serverless.yml, serverless-s3-remover doesn't return an accurate error message:
$ aws s3 rb s3://test-bucket-rmarable --force remove_bucket: test-bucket-rmarable
$ aws s3api head-bucket --bucket test-bucket-rmarable An error occurred (404) when calling the HeadBucket operation: Not Found
$ sls remove S3 Remover: Make test-bucket-rmarable empty. Are you sure? [yes/no]: yes S3 Remover: Faild: test-bucket-rmarable may not be empty.
What should happen instead:
$ sls remove S3 Remover: Make test-bucket-rmarable empty. Are you sure? [yes/no]: yes S3 Remover: Faild: test-bucket-rmarable does not exist.
This issue was mentioned in #12 but doesn't seem to have been explicitly addressed.
Thanks for making this very useful plugin available.