slackMessageBuilder()

in source/lambda/services/slacknotify/lib/slack-notify.js [87:169]


  slackMessageBuilder(event) {
    const _self = this;
    let _notifyColor = '#93938f';
    if (event.detail['status'] === 'OK') _notifyColor = '#36a64f';
    if (event.detail['status'] === 'WARN') _notifyColor = '#eaea3c';
    if (event.detail['status'] === 'ERROR') _notifyColor = '#bf3e2d';

    let _status = event.detail['status'];
    if (_status === 'OK') _status = `🆗`;
    if (_status === 'WARN') _status = `⚠️`;
    if (_status === 'ERROR') _status = `🔥`;

    /*
     * SO-Limit-M-41 - 07/30/2018 - Slack mapping
     * Fixed slack notification mapping
     */
    let _slackMssg = {
      attachments: [
        {
          color: _notifyColor,
          fields: [
            {
              title: 'AccountId',
              value: `${event.account}`,
              short: true,
            },
            {
              title: 'Status',
              value: _status,
              short: true,
            },
            {
              title: 'TimeStamp',
              value: `${event.time}`,
              short: true,
            },
            {
              title: 'Region',
              value: `${event.detail['check-item-detail']['Region']}`,
              short: true,
            },
            {
              title: 'Service',
              value: `${event.detail['check-item-detail']['Service']}`,
              short: true,
            },
            {
              title: 'LimitName',
              value: `${event.detail['check-item-detail']['Limit Name']}`,
              short: true,
            },
            {
              title: 'CurrentUsage',
              value: `${event.detail['check-item-detail']['Current Usage']}`,
              short: true,
            },
            {
              title: 'LimitAmount',
              value: `${event.detail['check-item-detail']['Limit Amount']}`,
              short: true,
            },
          ],
          pretext: '*Limit Monitor Update*',
          fallback: 'new notification from AWS Limit Monitor',
          author_name: '@aws-limit-monitor',
          title: 'Limit Monitor Documentation',
          title_link:
            'https://aws.amazon.com/answers/account-management/limit-monitor/',
          footer: 'Take Action?',
          actions: [
            {
              text: 'AWS Console',
              type: 'button',
              url:
                'https://console.aws.amazon.com/support/home?region=us-east-1#',
            },
          ],
        },
      ],
    };

    return _slackMssg;
  }