AWS - Send Scheduled Events notifications with text message or HipChat message - amazon-web-services

I know that the AWS sends emails about any EC2 instances with Scheduled Events, but I would also like to have these notifications sent through HipChat and text message as well. Is there a default way of selecting a setting that can do this in AWS? Or would I have to create a more custom solution to achieve this?

With Scheduled Events in EC2 being manual tool for monitoring health of instances as of right now, there isn't many options. From the design point of view on AWS platform, this could be one possible solution:
Create AWS SES mailbox and enable it to receive emails,
Create a forwarding rule in your original e-mail inbox where you receive those e-mail notifications from AWS about Scheduled Events to forward e-mails of this type (based on filter you define) to the previously created AWS SES mailbox,
In your AWS SES mailbox create "Receipt Rule" with SNS Action, that will basically publish entire content of the e-mail to the SNS Topic using AWS SNS. (The SNS topic you choose must be in the same AWS region as the Amazon SES endpoint you use to receive email)
Once that e-mail content lands in AWS SNS Topic as an event, you can use AWS Lambda subscribed to your SNS topic as a handler of the event, parse what you need and forward customized notification to any of your third-party (outside of AWS) alerting tools (such as PagerDuty, Slack channel, HipChat, or whatever you use for SMS notifications).
This design does have one week point: relying onto your external mailbox forwarding system (if you are receiving Scheduled Events e-mails in inbox not based on AWS SES).
Ideally you could try to see in your AWS Account settings if it is possible to use AWS SES mailbox for Scheduled Events notifications, but I haven't tried that.

You can receive text messages as notification by setting alarm for that ec2 instance e.g if CPU usages goes above 80% then create an alarm and eventually you can set it to get emails or text messages. Thanks

Related

AWS Cloudwatch alarms repeated notifications to slack

I'm successfully deployed solution described in AWS blog that enables repeated notifications on CloudWatch Alarms utilizing the alarm’s state change event via Amazon EventBridge and AWS Step Function.
There is a site which describe this:
https://github.com/aws-samples/amazon-cloudwatch-alarms-repeated-notification-cdk
It is able to send valid e-mail notifications, but the problem is to send it to Slack channel. I was overwhelmed by the problem of an incorrect message format being sent to a slack channel.
I'm looking for solution which can send repeated notification to Slack or how to change that code.

How to get forecasted AWS alerts/outages in email?

2 weeks back, I saw a notification in AWS saying, the one of the 3 AWS EC2 instance will be stopped because of the underlying hardware cause. I almost missed the dead line as I didn't the notification via email. Is there a way get these notification via email?
It would be much better if I can get the notifications using cloud watch to my email.
If you're on Business or Enterprise Support, AWS provides a solution named "AWS Health Aware" built on top of AWS Health API, it does exactly what you're after sends you notifications via several methods including emails regarding outages and planning maintenance that affect your account(s).
If you're on a Basic support plan you can easily built something similar yourself using based on [AWS Health events][2]
This is an example of capturing AWS Health events via EventBridge so they can be further send to a lambda or SNS
https://docs.aws.amazon.com/health/latest/ug/cloudwatch-events-health.html
What I've done in the is following:
Capturing AWS Health events via EventBridge in spoke accounts and forward them to the event bus in my hub account
In the hub account I would subscribe a lambda function for all events with source "aws.health" and then send email or slack message whatever works for you.
I think Amazon EventBridge is what you are looking for. With EventBridge you can detect and react to different events such as EC2 instances scheduled for updates. You can, for example, create a rule for detecting a specific health event and in the target section choose to receive an email through SNS or invoke a CloudWatch log group, etc. Read more here.

aws calling lambda on cloudwatch alarm - Only email lists for this account are available

On AWS I'm trying to create a cloudwatch alarm that sends a notification to a sns topic that in turn triggers a lambda function that is subscribed to the topic, but have run into a bit of a snag in which my lambda is never triggered. I've followed several tutorials on how to do this, I've manually tested the sns -lambda connection and this is working as is attaching the notification trigger onto cloudwatch.
I've done this all through cloudformation.
I have also tried to configure it manually from the cloudwatch console and then noticed something strange. Underneath the Send a notification to select box as shown in the image below, there is a message which says Only email lists for this account are available. So I'm guessing from that, that somewhere in this account, there is a weird setting that needs to be changed?
Updated answer:
Is the CloudWatch alarm actually in the "Alarm" state? Can you add 2 more notifications to be triggered by the "OK" and "Insufficient data" state respectively?
by reading the original post, SNS should have the right permission to invoke the Lambda function.
previous answer:
That is a general message, it has nothing to do with your SNS topic settings. I reckon it's meant to say only emails opt-in to that SNS topic will get emails.
Q: How does Amazon SNS validate a subscription request to ensure that notifications will not be sent to users as spam?
As part of the subscription registration, Amazon SNS will ensure that notifications are only sent to valid, registered subscribers/end-points. To prevent spam and ensure that a subscriber end-point is really interested in receiving notifications from a particular topic, Amazon SNS requires an explicit opt-in from subscribers using a 2-part handshake:
i. When a user first calls the Subscribe API and subscribes an end-point, Amazon SNS will send a confirmation message to the specified end-point.
ii. On receiving the confirmation message at the end-point, the subscriber should confirm the subscription request by sending a valid response. Only then will Amazon SNS consider the subscription request to be valid. If there is no response to the challenge, Amazon SNS will not send any notifications to that end-point. The exact mechanism of confirming the subscription varies by the transport protocol selected:
For HTTP/HTTPS notifications, Amazon SNS will first POST the confirmation message (containing a token) to the specified URL. The application monitoring the URL will have to call the ConfirmSubscription API with the token included token.
For Email and Email-JSON notifications, Amazon SNS will send an email to the specified address containing an embedded link. The user will need to click on the embedded link to confirm the subscription request.
For SQS notifications, Amazon SNS will enqueue a challenge message containing a token to the specified queue. The application monitoring the queue will have to call the ConfirmSubscription API with the token.
Note: The explicit “opt-in” steps described above are not required for the specific case where you subscribe your Amazon SQS queue to your Amazon SNS topic – and both are “owned” by the same AWS account.

Customize alarm message from AWS Cloudwatch

I got some alarm notifications from AWS Cloudwatch to my email but they are usually sent in a JSON format and the problem is that some of those emails are getting received by non-technical people in my company. I was wondering if that is possible to customize the emails sent by AWS SNS because I don't see any option in how to customize it.
If you are using Cloudwatch/Event/Rules then you can use "Input transfomer" to customize the contents of the email and then SNS will send that instead of JSON.
I am using this setup to get notified when user signs in AWS console.
In my case "Event Source" is "AWS Console Sign-in" but you can try with Cloudwatch and see if that gets you what you need.
See the screenshot, hope it helps.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/CloudWatch-Events-Input-Transformer-Tutorial.html
https://forums.aws.amazon.com/thread.jspa?messageID=820808
you trigger a lambda function from your SNS topic, take the event and either send it via SNS or SES. SES supports sending HTML mails, SNS just plain text mails.
I normally do the following approach:
Alarm -> SNS -> Lambda -> SES (HTML)
received by non-technical people in my company
I'd use a basic HTML template with buttons and nice looking text :-)
I created a post and a GitHub repository for that:
https://medium.com/#sandro_volpicella/how-to-customise-cloudwatch-alarm-notifications-with-lambda-ses-html-and-cdk-f0094b07fed6
https://github.com/AlessandroVol23/cloudwatch-custom-email-cdk
I don't think you can change the notifications from SNS sent via e-mail.
If you really need to customize them, you should look into SNS notifications via SES (Simple Email Service)

Is it possible to have AWS CloudWatch Alarm send a notification to an SNS topic in another region?

I am trying to create CloudWatch alarms in N. California region because that is where my EC2s are.
I want to send a notification to an SNS topic that supports both email and SMS, which n. california does not, so I created an SNS topic in Oregon instead which supports both.
The topic does not appear in the "Send Notification To:" dropdown, reading online it seems like i'm supposed to be able to click 'enter list' and put in an ARN from another region, however when I do this I get an error saying:
Error:
There was an error saving the alarm. Please try again.
Cross region SNS will not be available to be configured for CloudWatch alarm notifications.
Alternatively, the following steps will help you achieve the same though not a fancy way of doing.
Configure a SNS in the same region and configure CloudWatch to send alarm notifications to this SNS in the same region
Subscribe a Lambda as a consumer for this SNS to listen and process the events sent from CloudWatch
The Lambda will reside in the same region which will receive the event from local SNS and publish (literally forward) the message (using SNS publish method) to the SNS in a different region.
The SNS in other region can have SMS and/or email subscriptions.