From 4b661e5c8c2d8d1ea5d1bb901e8d38374c333a92 Mon Sep 17 00:00:00 2001 From: Kathy Tran Date: Wed, 11 Dec 2024 11:39:09 -0500 Subject: [PATCH] Display task container names for ECS task state change events (#175) https://ucsc-cgl.atlassian.net/browse/SEAB-6746 --- cloud-watch-to-slack-testing/deployment/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cloud-watch-to-slack-testing/deployment/index.js b/cloud-watch-to-slack-testing/deployment/index.js index 3b2c448..38c8d6f 100644 --- a/cloud-watch-to-slack-testing/deployment/index.js +++ b/cloud-watch-to-slack-testing/deployment/index.js @@ -258,6 +258,13 @@ function ecsTaskStateChangeMessageText(message) { const taskArn = message?.detail?.taskArn; const lastStatus = message?.detail?.lastStatus; let messageText = `Task ${taskArn} is now ${lastStatus}`; + const taskContainers = message?.detail?.containers; + if (Array.isArray(taskContainers)) { + const taskContainerNames = taskContainers + ?.map((container) => container.name) + ?.join(", "); + messageText += `\nContainers: ${taskContainerNames}`; + } ["startedAt", "stoppedAt", "stoppedReason"].forEach((name) => { const value = message?.detail?.[name]; if (value != undefined) {