claygregory/serverless-prune-plugin

How to prune only one AWS lambda function if there are multiple lambdas configured in one serverless.yml file?

Closed this issue · 3 comments

bsk25 commented

Problem Statement :

In serveless.yml we can configure multiple lambda functions under the functions key.

But now if we use the serverless-prune-plugin then the prune setting would get applied to all the lambdas.

How to restrict the pruning to just a specific lambda inside this serverless.yml file.?

Note : This needs to be done for automatic pruning.

Hi @bsk25

Right, currently automatic pruning is applied at the project-level, not function level. Can you describe a specific use-case for wanting to prune with differing parameters between functions?

I'm trying to gauge if this is best handled in the plugin because it's a relatively common need, or if you have a bit of an edge-case best handled externally: for example, you could have your CI/CD pipeline use the sls prune -f functionName CLI command with specific configurations for each function and achieve your desired result.

bsk25 commented

Hello @claygregory ,

Wanted to test this for one lambda first in dev before deploying to PROD.
So, was checking if there is a configuration to restrict this to just one function.

Eventually, will be doing it at project-level.

Ah. Got it. Well then:

  • I assume you're separating dev/prod by Serverless stage. Good news: prune always acts on the target stage within a target region. So in the case of automatic pruning, it will only prune to the stage/region to which you just deployed.
  • If manually pruning, you can specifically test pruning against a single function. You can also target a specific region or stage from the cli.

Hope this helps.