From 63315306a87ed409cf48eb7997bb8779c7538d04 Mon Sep 17 00:00:00 2001 From: Chris Kalafarski Date: Fri, 28 Jun 2024 10:19:21 -0400 Subject: [PATCH] Include account in notification --- src/slack-notifications/accounts.mjs | 28 ++++++++++++++++++++++++++++ src/slack-notifications/index.mjs | 3 +++ 2 files changed, 31 insertions(+) create mode 100644 src/slack-notifications/accounts.mjs diff --git a/src/slack-notifications/accounts.mjs b/src/slack-notifications/accounts.mjs new file mode 100644 index 0000000..ee87104 --- /dev/null +++ b/src/slack-notifications/accounts.mjs @@ -0,0 +1,28 @@ +export default function accounts(accountId) { + switch (accountId) { + case "561178107736": + return "PRX Legacy"; + case "578003269847": + return "PRX DevOps"; + case "048723829744": + return "PRX Main"; + case "856014627802": + return "PRX Feed CDN Staging"; + case "838846856186": + return "PRX Feed CDN Production"; + case "976680550710": + return "The World"; + case "151502348212": + return "PRX Data Production"; + case "639773875692": + return "PRX publicmedia.social"; + case "874261868300": + return "PRX Dovetail CDN Staging"; + case "485319730460": + return "PRX Dovetail CDN Production"; + case "127213743756": + return "PRX IT Services"; + default: + return accountId; + } +} diff --git a/src/slack-notifications/index.mjs b/src/slack-notifications/index.mjs index bf85957..a1dd6de 100644 --- a/src/slack-notifications/index.mjs +++ b/src/slack-notifications/index.mjs @@ -2,6 +2,7 @@ import { EventBridgeClient, PutEventsCommand, } from "@aws-sdk/client-eventbridge"; +import accountName from "./accounts.mjs"; const eventbridge = new EventBridgeClient({ apiVersion: "2015-10-07" }); @@ -34,6 +35,7 @@ export const handler = async (event) => { }), ); + const accountId = event.detail.affectedAccount; const region = event.detail.eventRegion; const { service } = event.detail; const code = event.detail.eventTypeCode; @@ -68,6 +70,7 @@ export const handler = async (event) => { text: [ `*Service:* ${service}`, `*Region:* ${region}`, + `*Account:* ${accountName(accountId)}`, `*Event Code:* ${code}`, "\n", `*Started:* ${timeSince(new Date(startTs))} ago`,