Skip to content

Commit

Permalink
Check if array
Browse files Browse the repository at this point in the history
  • Loading branch information
kathy-t committed Dec 11, 2024
1 parent 57572ea commit ca71d0f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cloud-watch-to-slack-testing/deployment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +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
?.map((container) => container.name)
?.join(", ");
messageText += `\nContainers: ${taskContainers}`;
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 ca71d0f

Please sign in to comment.