• Pricing
© 2026 Serverless, Inc. All rights reserved.

Framework

  • Overview
  • Documentation
  • Plugins360
  • Pricing

Learn

  • Blog
  • GuidesUpdated
  • Examples240
  • Courses

Resources

  • Support
  • Security
  • Trust Center
  • Status

Community

  • Slack
  • GitHub47k
  • Forum
  • Meetups

Company

  • About
  • Careers
  • Contact
  • Partners

Legal

  • Terms of Service
  • Privacy Policy
  • Trademark
  • DMCA
go-dima

Serverless Plugin Conditional Functions

by

A plugin that allows adding simple feature flag per function via a boolean condition.

0
10
  1. Serverless Plugin Conditional Functions

npm version Build Status npm downloads

NPM

Serverless Plugin Conditional Functions

This plugin allows you to add a custom condition to each function in your serverless.yml, to toggle the deployment of your functions. Effectively, it allows a simple feature-flag per function.

For example, if you want to deploy a function for testing only, but don't want it in production, or vice-versa. The attribute supports simple true/false usage or more complex (see below) conditions.

Installation

npm i serverless-plugin-conditional-functions --save-dev

Example

service: MyCustomService
provider:
  name: aws
  runtime: java8
  stage: ${opt:stage,'test'}
  region: ${opt:region,'us-east-1'}

plugins:
  - serverless-plugin-conditional-functions

functions:
  func1:
    enabled: '"${self:provider.stage}" == "prod"'
    handler: com.example.functions.Func1Handler
    events:
      - http:
          path: func1
          method: GET
          integration: lambda
  func2:
    enabled: '"${self:provider.stage}" != "prod"'
    handler: com.example.functions.Func2Handler
    events:
      - http:
          path: func2
          method: GET
          integration: lambda
  func3:
    enabled: 'false'
    handler: com.example.functions.Func3Handler
    events:
      - http:
          path: func3
          method: GET
          integration: lambda

Contents

  • Serverless Plugin Conditional Functions
  • Installation
  • Example

Related

GuidesPluginsExamplesSlack CommunitySupport