updateTable()

in source/lambda/services/limitreport/lib/limit-report.js [144:182]


  updateTable(payload, cb) {
    let ta_mssg = JSON.parse(payload.Body);
    let params = {
      TableName: this.ddbTable,
      Item: {
        MessageId: payload.MessageId,
        AccountId: ta_mssg.account,
        TimeStamp: ta_mssg.time,
        Region: ta_mssg.detail['check-item-detail']['Region'],
        Service: ta_mssg.detail['check-item-detail']['Service'],
        LimitName: ta_mssg.detail['check-item-detail']['Limit Name'],
        CurrentUsage: ta_mssg.detail['check-item-detail']['Current Usage'],
        LimitAmount: ta_mssg.detail['check-item-detail']['Limit Amount'],
        Status: ta_mssg.detail['status'],
        ExpiryTime: new Date().getTime() + 15 * 24 * 3600 * 1000, //1️⃣5️⃣ days
      },
    };
    LOGGER.log('DEBUG', `DDB put item: ${JSON.stringify(params)}`);

    this.docClient.put(params, function(err, data) {
      if (err) {
        return cb(
          {
            TableUpdate: {
              status: err,
            },
          },
          null
        ); //🔥
      } else {
        return cb(null, {
          TableUpdate: {
            status: 'success',
            //receipthandle: payload.ReceiptHandle
          },
        });
      }
    });
  }