Skip to content

Instantly share code, notes, and snippets.

@nwalke
Created June 26, 2017 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nwalke/c11d11a9d3ddd3f17c0cee4596d67ec8 to your computer and use it in GitHub Desktop.
Save nwalke/c11d11a9d3ddd3f17c0cee4596d67ec8 to your computer and use it in GitHub Desktop.
{
"region": "us-west-1",
"accountId": "111222333444",
"eventTriggerName": "Trigger-group-us-west-3-deploy-failed",
"applicationName": "ProductionApp-us-west-3",
"deploymentId": "d-75I7MBT7C",
"deploymentGroupName": "dep-group-def-456",
"createTime": "1446744188.595",
"completeTime": "1446744190.402",
"deploymentOverview": {
"Failed": "10",
"InProgress": "0",
"Pending": "0",
"Skipped": "0",
"Succeeded": "0"
},
"status": "Failed",
"errorInformation": {
"ErrorCode": "IAM_ROLE_MISSING",
"ErrorMessage": "IAM Role is missing for deployment group: dep-group-def-456"
}
}
@bharley
Copy link

bharley commented Jun 26, 2017

Assuming this is in an object called response:

const overview = response.deploymentOverview;
const nonSucceeded = Object.keys(overview)
  .filter(key => key !== 'Succeeded')
  .reduce((sum, key) => sum + parseInt(overview[key], 10), 0);

if (nonSucceded > 0) {
  // Uh oh
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment