Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

I am trying to exclude a Lambda function from being deployed via serverless to my prod stage within AWS.

A snippet from my serverless YAML looks something like -

functions:

  some-prod-function:

    handler: prodFunction.handler

    events:

      - http:

          path: /prod-function

          method: post

  some-dev-function:

    handler: devFunction.handler

    events:

      - http:

          path: /dev-function

          method: post

Is there a way to exclude some-dev-function from being deployed to prod?

1 Answer

0 votes
by (44.4k points)

You can use variables to choose whichever definition to use by putting those definitions on a different property.

environment-functions:

  prod:

    some-prod-function:

      handler: prodFunction.handler

      events:

        - http:

            path: /prod-function

            method: post

  dev:

    some-dev-function:

      handler: devFunction.handler

      events:

        - http:

            path: /dev-function

            method: post

functions: ${self:environment-functions.${opt:stage}}

According to your stage of deployment  (${opt:stage} or ${env:stage}), you have to change it.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...