Amazon EC2 state change notification post to Slack.
-
Runtime : Node.js 10.x
-
This code using slack custom emoji ":aws:" and ":ec2:". Those icon pictures are using AWS Architecture Simple Icon.
-
Environment variable
key value hookUrl Slack webhook url slackChannel target slack channel
-
Enable AWS CloudTrail.
-
Create Amazon CloudWatch event rule.
Event pattern Service Name EC2 Event type EC2 Instance State-change Notification State Any *1 Instance Any *1 Target Lambda function *1 : Change when specifying a specific state or instance.
-
Create Lambda function with this code.
mm948