terraform-aws-modules / terraform-aws-lambda

Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/lambda/aws
Apache License 2.0
886 stars 656 forks source link

Limit number of available Lambda versions #519

Closed extsoft closed 7 months ago

extsoft commented 7 months ago

Is your request related to a new offering from AWS?

No

Is your request related to a problem? Please describe.

I'm using Lambda function versioning with Aliases. Every code change creates a new function version. Over time, there is a list of the old versions that are no longer relevant. I would like to get them removed automatically due to

  1. the old versions of the functions could be dangerous to deploy; someone could deploy them manually
  2. the function storage (code and layers) is limited to 75GB (AWS Lambda quotas); I would like to optimize its usage

Describe the solution you'd like.

An input called versions_to_keep (defaults to 50). For instance, versions_to_keep = 5 means that the 5 resent versions of the function must remain; the rest must be removed.

Additional context

Serverless framework has a plugin for this task.

antonbabenko commented 7 months ago

There is no native way to control such a number using Terraform AWS provider resources (AFAIK) - https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function

Such a solution should be a part of a dedicated module for solutions - https://github.com/terraform-aws-modules/terraform-aws-solutions

Pull requests are welcome.

github-actions[bot] commented 6 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.