sinofseven / serverless-s3-remover

this is plugin of serverless, before "sls remove", this empties the s3 bucket.
MIT License
39 stars 11 forks source link

Should be able to make sure that objects are not removed when stage is set to production #7

Open ghost opened 6 years ago

ghost commented 6 years ago

It feels dangerous that you can destroy all of the data in production with a single accidental command. This plugin should allow you to specify no action given a specific stage setting. That way there is at least some protection from erasing all production data.

sinofseven commented 6 years ago

I think your concern is correct. You can display the prompt before deleting the object with the PR you received earlier. Can you satisfy your request with this function?


Using Prompt

You can use prompt before deleting bucket.

custom:
  remover:
    prompt: true # default value is `false`
    buckets:
      - remover-bucket-a
      - remover-bucket-b

terminal.png

ghost commented 6 years ago

I think that is a great solution if you are manually uploading. What if the prompt displayed by default if your env was set to prod or production? Either way, it is a great solution, though I would still be concerned about an automated process. How about if you allow a user to specify when to take no action in their yml file? For example:

custom:
  remover:
    no-action:
      stage: production
      env:
        - no-delete
    buckets:
      - remover-bucket-a
      - remover-bucket-b

In this case, if the stage was set to production OR and environment variable was set to no-delete, no action would be taken. I think the stage is the most important thing, I put the env distinction in there to cover any other use cases that might have the same concern.

sepehr commented 6 years ago

This would be a very handy feature to have.

onhate commented 5 years ago

For those getting into this issue willing to have different cleanup setup for each environment, this is the approach I used and it works fine.

custom:
  remover-config:
    default:
      buckets:
        - a-bucket-name-goes-here
    prod:
      buckets: []
  remover: ${self:custom.remover-config.${self:custom.stage}, self:custom.remover-config.default}