Ignore function deploy depending to environment stage

In my serverless service I have 3 function and two stages (development, production).

  • Function A must run only in production stage
  • Function B must run for both stage
  • Function C must run only in development stage

I don’t want A is deployed in cloudformation stack for development stage and I don’t want C is deployed in production stage.

I solved partially the problem in this way for A function:

events:
  - iot:
      name: DeviceDataReceived-r1x-${opt:stage}
      description: --
      enabled : ${opt:stage == production}
      sql: "SELECT * FROM 'devices/+/things'"
      sqlVersion: beta

But it’s useless to deploy a function (and allocate all resource it needs) which will be always disabled.