Skip to content

Commit

Permalink
Display task container names for ECS task state change events (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
kathy-t authored Dec 11, 2024
1 parent 1a1719e commit 4b661e5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cloud-watch-to-slack-testing/deployment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4b661e5

Please # to comment.