Search code examples
amazon-web-servicesaws-lambdaserverless-framework

How to Exclude Specific Lambdas When Deploying Serverless Applications?


I only use some lambdas in my local development environment. However, they are in the same serverless.yml file as the other lambdas that I use in both development and production environments.

I have looked in the documentation but could not find any information on whether it is possible to specify a parameter or something else to indicate that certain lambdas should not be deployed when running sls deploy.

Thank you in advance for your help.


Solution

  • Use the serverless-plugin-ifelse plugin.

    the 'If' condition can range , but , example. assuming your function name is func3

    plugins:
      - serverless-plugin-ifelse
        
    custom:
      serverlessIfElse:
          - If: '"${self:custom.currentStage}" != "local"'
            Exclude:
              - functions.func3