# Disable Function Per Stage?

**URL:** <https://forum.serverless.com/t/disable-function-per-stage/604>\
**Category:** Serverless Framework\
**Created:** [October 20, 2016, 11:22pm UTC](https://forum.serverless.com/t/disable-function-per-stage/604 "2016-10-20T23:22:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AdamM](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/adamm/32/239_2.png) [@AdamM](https://forum.serverless.com/u/AdamM)\
**Post date:** [October 20, 2016, 11:22pm UTC](https://forum.serverless.com/t/disable-function-per-stage/604/1 "2016-10-20T23:22:00Z")

</div>

Hi,

Some of our functions can’t be deployed to certain stages.  
How can I disable the function based on stage?  
Is there an expression capability in the yml?

Thanks

---

<div class="post-metadata">

**Author:** ![johncmckim](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/johncmckim/32/27_2.png) [@johncmckim](https://forum.serverless.com/u/johncmckim)\
**Post date:** [October 21, 2016, 12:59am UTC](https://forum.serverless.com/t/disable-function-per-stage/604/2 "2016-10-21T00:59:38Z")

</div>

Hi Adam,

As far as I’m aware this functionality doesn’t exist.

I assume there are certain functions you don’t want deployed to production? What’s the use case? What problem are you trying to solve?

Can you separate the functions that can’t be deployed to certain stages into separate projects that are deployed separately?

---

<div class="post-metadata">

**Author:** ![rowanu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rowanu/32/75_2.png) [@rowanu](https://forum.serverless.com/u/rowanu)\
**Post date:** [October 21, 2016, 2:39am UTC](https://forum.serverless.com/t/disable-function-per-stage/604/3 "2016-10-21T02:39:12Z")

</div>

+1 all the things @johncmckim said.

If your functions can’t be deployed to the same stage(s), they don’t belong in the same service.

---

<div class="post-metadata">

**Author:** ![adambiggs](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/adambiggs/32/235_2.png) [@adambiggs](https://forum.serverless.com/u/adambiggs)\
**Post date:** [October 21, 2016, 3:15am UTC](https://forum.serverless.com/t/disable-function-per-stage/604/4 "2016-10-21T03:15:13Z")

</div>

This might actually be related to the [issue I recently opened](http://forum.serverless.com/t/deploying-ddb-stream-events-to-specific-stage-with-v1/595) about our DynamoDB backup service.

When a DyanmoDB stream event is triggered, I don’t want all my Serverless stages to try to back up the same record.

---

<div class="post-metadata">

**Author:** ![AdamM](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/adamm/32/239_2.png) [@AdamM](https://forum.serverless.com/u/AdamM)\
**Post date:** [October 21, 2016, 4:13am UTC](https://forum.serverless.com/t/disable-function-per-stage/604/5 "2016-10-21T04:13:52Z")

</div>

My use case is we have develop, release and master stages.

The functions in question are maintenance jobs for our analytics. We don’t run analytics in the release stage and the develop stage doesn’t get enough data to warrant running the functions.

They are grouped with other functions that do get deployed. So u guess the answer is to seperate them into seperate projects

Having them deployed is no issue I guess by disabled I mean no triggers or in the case of develop different triggers to master would work

---

<div class="post-metadata">

**Author:** ![johncmckim](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/johncmckim/32/27_2.png) [@johncmckim](https://forum.serverless.com/u/johncmckim)\
**Post date:** [October 21, 2016, 6:04am UTC](https://forum.serverless.com/t/disable-function-per-stage/604/6 "2016-10-21T06:04:48Z")

</div>

> [@AdamM](#):
>
> Having them deployed is no issue I guess by disabled I mean no triggers or in the case of develop different triggers to master would work

@AdamM I would still deploy those functions but optionally disable certain logic per stage. You could do that by injecting the stage as an environment variable. You can then check the variable and not invoke certain logic based on that.

I wouldn’t avoid triggering those lambdas, otherwise how do you know those triggers actually work? Just stub out what you need to and log that it was triggered. That said, if you’re only execute code in production, you run a real risk of having issues that only appear in production.
