Example #1
0
function setEventSource(region, streamArn, fnName, invocationRole, callback) {
  var lambda = new AWS.Lambda({ region: region });

  lambda.listEventSources({
    EventSourceArn: streamArn,
    FunctionName: fnName
  }, function(err, data) {
    if (err) return callback(err);
    if (data.EventSources.length) return callback(null, data.EventSources[0].UUID);

    var params = {
      EventSource: streamArn,
      FunctionName: fnName,
      Role: invocationRole,
      BatchSize: 100,
      Parameters: {
        InitialPositionInStream: 'TRIM_HORIZON'
      }
    };

    fastlog.debug('addEventSource parameters');
    _(params).each(function(val, k) {
      fastlog.debug('%s = %s', k, val);
    });

    lambda.addEventSource(params, function(err, data) {
      if (err) return callback(err);
      callback(null, data.UUID);
    });
  });
}
Example #2
0
  function(err,data) {
    if(err) {
      console.log(err);
    } else {
      var streamARN = data.StreamDescription.StreamARN;
      console.log('list event sources for %s', streamARN);



      lambda.listEventSources({
        EventSourceArn: streamARN,
        FunctionName: 'streamReader'
      }, function(err, data) {
        console.log(this.httpResponse.body.toString());
        if(err) {
          console.log(err);
          process.exit(1);
        } else {
          console.log(data);
        }
      });
    }
  });