Delete S3 buckets after deployment

Having a bunch of s3 buckets floating around for my deployments feels really messy. Is it possible to delete the s3 buckets after the deployment of a lambda function?

1 Like

That’s a bizarre coincidence, I just asked that question too Can I delete the S3 buckets that the serverless framework creates?

I wouldn’t.

From what I can tell it keeps the final CF template and values in there, so that when you do deploys later it helps keep things idempotent. Very similar to Terraform and it’s use of S3 buckets. I mean in theory you could delete them and let it regenerate them every time, but I think it’s safer to just let them be.

Or precreate a common bucket and configure all your serverless.yml to use that one rather than creating new ones all the time

1 Like

Has anyone found any solution yet, @alshdavid / @ColinEberhardt …?

I don’t mind regenerate meta data every time, I just want to remove all the S3 buckets that the serverless framework creates. thx

You could have a function triggered on schedule that found and removed the buckets.

Ah, good idea, will look into how to do that…