# SNS topic enabled/disabled

**URL:** <https://forum.serverless.com/t/sns-topic-enabled-disabled/2119>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [June 22, 2017, 3:39pm UTC](https://forum.serverless.com/t/sns-topic-enabled-disabled/2119 "2017-06-22T15:39:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris\_sf](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@chris\_sf](https://forum.serverless.com/u/chris_sf)\
**Post date:** [June 22, 2017, 3:39pm UTC](https://forum.serverless.com/t/sns-topic-enabled-disabled/2119/1 "2017-06-22T15:39:45Z")

</div>

Is there a way to disable sns topic events? I tried something like this:

> ```
> events:
> - sns:
> arn: [SNS_ARN]
> enabled: false
> 
> ```

I’d like to have the sns topic enabled on my production environment and disabled on my dev environment.

---

<div class="post-metadata">

**Author:** ![stephanechauvin](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@stephanechauvin](https://forum.serverless.com/u/stephanechauvin)\
**Post date:** [July 20, 2017, 12:08pm UTC](https://forum.serverless.com/t/sns-topic-enabled-disabled/2119/2 "2017-07-20T12:08:20Z")

</div>

Sorry I don’t know the answer of your main question…

But about the second part (enabling/disabling according to environnement), I use the following trick for schedule enabling

I have a js file with two functions :

_enabled.js :_

```auto
module.exports.dev = () => false;
module.exports.production = () => true;

```

_serverless.yml :_

```auto
functions:
  myfunc:
    #...
    events:
      - schedule: 
          #...
          enabled: ${file(./enabled.js):${opt:stage}}

```

I’m not sure it is the best way to do it, but it works 🙂

Note that with this example, the stage must be declared explicitely at deployment with `--stage` or `-s`.

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [July 22, 2017, 6:30am UTC](https://forum.serverless.com/t/sns-topic-enabled-disabled/2119/3 "2017-07-22T06:30:49Z")

</div>

`schedule` has an `enable` option that `sns` doesn’t seem to support.

@chris_sf I’d try setting something like

```auto
custom:
   dev:
      func:
        events:
   prod:
      func:
        events:
          - sns:
              arn: [SNS_ARN]
  stage: ${opt:stage, self:provider.stage}

```

then you could use

```auto
events: ${self:custom.${self:custom.stage}.func.events}

```
