GithubHelp home page GithubHelp logo

[SPEC V1] SNS subscriptions about serverless HOT 8 CLOSED

jwulf avatar jwulf commented on June 20, 2024
[SPEC V1] SNS subscriptions

from serverless.

Comments (8)

jwulf avatar jwulf commented on June 20, 2024

What would work is an SNS subscription function that takes a list of SNS subscriptions during deploy, and then just sets them up.

Something like this, but iterating over an array of objects:

module.exports.registerSNS(freq) {
  Lambda.getFunctionConfiguration({ FunctionName: thisLambdaFunctionName },
    function (err, data) {
      if (err) return console.log(err);
      var params = {
        Protocol: 'lambda',
        TopicArn: freq,
        Endpoint: data.FunctionArn
      };
      sns.subscribe(params, function (err, data) {
        if (err) return console.log(err, err.stack); // an error occurred
        if (!data.SubscriptionArn) {
          var confirm_params = {
            Token: 'STRING_VALUE', /* required */
            TopicArn: freq,
            AuthenticateOnUnsubscribe: 'STRING_VALUE'
          };
          sns.confirmSubscription(confirm_params, function (err, data) {
            if (err) return console.log(err, err.stack); // an error occurred
            else console.log(data);           // successful response
          });
        } else console.log('Note: Already subscribed to ' + data.SubscriptionArn);
      });
    });
}

Where would I specify the SNS subscriptions? In lambda.json? Or does it need a separate wiring.json file?

I'll probably extend it with other things as well, like registering workflow types, etc...

from serverless.

jwulf avatar jwulf commented on June 20, 2024

Pre- and post- deployment hooks in jaws deploy would allow easy prototyping and extensibility.

from serverless.

doapp-ryanp avatar doapp-ryanp commented on June 20, 2024

Pretty sure this will be fixed in the v1.0.0 branch. Current deploy deletes then re-creates lambda which is causing SNS breakage. New code will do update and preserve. I like the idea of hooks.

from serverless.

jwulf avatar jwulf commented on June 20, 2024

Cool. We also need a mechanism to create them initially (and to function as documentation of the app's structure).

from serverless.

doapp-ryanp avatar doapp-ryanp commented on June 20, 2024

I don't think hooking up SNS to invoke lambda is in the scope of JAWS. Just my opinion though.

from serverless.

austencollins avatar austencollins commented on June 20, 2024

I do like the idea of the pre/post deploy hooks. I'm going to think about that. Maybe those are just functions you can specify in the JSON file located in the lambda's folder. Super simple.

from serverless.

jwulf avatar jwulf commented on June 20, 2024

This request is fulfilled by #214 - thanks to @dekz

from serverless.

austencollins avatar austencollins commented on June 20, 2024

Event support is in v0.4

from serverless.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.