Upon reading of this article which discusses the main drawback of using AWS Lambda functions, I'm trying to avoid what the author had to deal with and perform some cleanup on my own code:
"Lambda versions every function. We use the Serverless Framework for developing Lambda application. This means that Serverless creates Lambda functions. Our average Lambda function is about 60MB. [...]
When you couple CI/CD with rapid development and Lambda functions, you get many versions. Hundreds even. And Lambda code storage is limited to 75GB. We hit that limit, and we hit it hard. After two years of CI/CD driven development, our lack of version cleanup led to complete gridlock in our development process."
(emphasis mine)
About my architecture. I have lambda functions that call methods from homemade python packages, which are stored in layers. The goal being to avoid having too much code in the lambdas and easily reuse features among them.
Now, I have found how to remove old versions of my lambda functions (I too am using the Serverless framework, which offers a nice plugin for automatically pruning them upon deployment of the stack). However, I don't know whether old layers are automatically deleted by AWS: I have yet to find a dashboard that summarizes the total code size of all my layer versions, and I couldn't find a plugin that automatically removes them.
Are old AWS Lambda layers automatically removed? If not, how could I batch delete them?