-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move global lodash to eventdef.js, start using it
- Loading branch information
Showing
16 changed files
with
67 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,46 @@ | ||
// | ||
// AWS Auto-Scaling event parser | ||
// | ||
const _ = require("lodash"); | ||
module.exports.matches = event => | ||
_.has(event.message, "AutoScalingGroupARN"); | ||
|
||
module.exports = { | ||
module.exports.parse = event => { | ||
const message = event.message; | ||
const accountId = _.get(message, "AccountId"); | ||
//const requestId = _.get(message, "RequestId"); | ||
const arn = _.get(message, "AutoScalingGroupARN"); | ||
const groupName = _.get(message, "AutoScalingGroupName"); | ||
const service = _.get(message, "Service"); | ||
const eventName = _.get(message, "Event"); | ||
|
||
matches: event => _.has(event.message, "AutoScalingGroupARN"), | ||
|
||
parse: event => { | ||
const message = event.message; | ||
const accountId = _.get(message, "AccountId"); | ||
//const requestId = _.get(message, "RequestId"); | ||
const arn = _.get(message, "AutoScalingGroupARN"); | ||
const groupName = _.get(message, "AutoScalingGroupName"); | ||
const service = _.get(message, "Service"); | ||
const eventName = _.get(message, "Event"); | ||
|
||
// Example ARN: arn:aws:autoscaling:{region}:{accountId}:autoScalingGroup:{group-id}:autoScalingGroupName/{group-name} | ||
const arnParts = _.split(arn, ":"); | ||
let region; | ||
if (arnParts.length >= 0) { | ||
region = arnParts[3]; | ||
} | ||
// Example ARN: arn:aws:autoscaling:{region}:{accountId}:autoScalingGroup:{group-id}:autoScalingGroupName/{group-name} | ||
const arnParts = _.split(arn, ":"); | ||
let region; | ||
if (arnParts.length >= 0) { | ||
region = arnParts[3]; | ||
} | ||
|
||
const signInLink = `https://${accountId}.signin.aws.amazon.com/console/ec2?region=${region}`; | ||
const consoleLink = `https://console.aws.amazon.com/ec2/autoscaling/home?region=${region}#AutoScalingGroups:id=${groupName}`; | ||
const signInLink = `https://${accountId}.signin.aws.amazon.com/console/ec2?region=${region}`; | ||
const consoleLink = `https://console.aws.amazon.com/ec2/autoscaling/home?region=${region}#AutoScalingGroups:id=${groupName}`; | ||
|
||
const text = `Auto Scaling triggered ${eventName} for service ${service}.`; | ||
const text = `Auto Scaling triggered ${eventName} for service ${service}.`; | ||
|
||
return event.attachmentWithDefaults({ | ||
author_name: `AWS AutoScaling (${region} - ${accountId})`, | ||
author_link: signInLink, | ||
title: `${groupName} - ${eventName}`, | ||
title_link: consoleLink, | ||
text, | ||
fallback: text, | ||
color: event.COLORS.neutral, | ||
fields: [{ | ||
title: "Service", | ||
value: service, | ||
short: true, | ||
}, { | ||
title: "Event", | ||
value: eventName, | ||
short: true, | ||
}] | ||
}); | ||
} | ||
return event.attachmentWithDefaults({ | ||
author_name: `AWS AutoScaling (${region} - ${accountId})`, | ||
author_link: signInLink, | ||
title: `${groupName} - ${eventName}`, | ||
title_link: consoleLink, | ||
text, | ||
fallback: text, | ||
color: event.COLORS.neutral, | ||
fields: [{ | ||
title: "Service", | ||
value: service, | ||
short: true, | ||
}, { | ||
title: "Event", | ||
value: eventName, | ||
short: true, | ||
}] | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters