AWS Cloudwatch set up WebHook - amazon-web-services

I am having trouble in defining a webhook on AWS CloudWatch(I am new to this technology). I checked out a lot of forums but I could not find out the right answer. Basically, what I need is a webhook or a similar way for sending an alert from CloudWatch to a web server via http post, every time the alert is generated.
Any help would be greatly appreciated!

Configure CloudWatch to send the alert to an SNS topic. Then have SNS send the message to an HTTP endpoint.

Related

How to configure AWS Chatbot to deliver useful messages from Beanstalk to Slack?

We have an Elastic Beanstalk deployment and wanted to receive events into our Slack channel. We setup EventBridge and Chatbot to deliver notifications. Everything works, except the notifications are useless, because Chatbot does not map the message detail only the detail type, which does not tell much. See the attached image of a notification (cropped to cut out the region/account info), the message is not too useful without telling us what was the actual change, which is in the event received by EventBridge and sent to SNS, but not mapped by Chatbot when sending to Slack.
Even their example test notification demonstrates the same problem:
I checked the Chatbot documentation where they claim support for multiple services via EventBridge. I checked EventBridge documentation where they list Elastic Beanstalk among supported services.
I also subscribed and tested Health service notifications, which work just fine. See the example test notification below.
I could not find a way to configure Chatbot to do the right thing. I could write my own message transformer for certain events and call a Slack webhook instead of using Chatbot, but I wanted to avoid writing custom code here for now.
Does anyone know if it is possible to fix Beanstalk notifications that are sent from EventBridge to Chatbot then to Slack? Or is AWS working on supporting more service notifications and in the future this might start working as it should?
Thank you in advance.

Ip or iam user from which Publish message request made to sns topic?

I have a lambda function that is invoking around 60million times from one sns topic, in the sns topic metrics i could see it is publish around 600k msgs but I wanted to know how we can check which iam user has made the publish message request in that topic and how can we get the IP from which message are published?
As for as I know there is no way you can monitor what you are asking for. What you can do is to search ClouTrail logs and figure out yourself which user made how many requests to sns. There is also a way to put the logs(CloudTrail) in CloudWatch but it's not cheap process. If you are interested, you check this.

Investigate AWS SNS without any side effects?

As you know, we can publish to an SNS events via those channels:
HTTP
HTTPS
Email
Email-JSON
Amazon SQS
AWS Lambda
Platform application endpoint
SMS
Now let's say I want to test a published messsage.
According to the list, I can use a "request catcher service" for Http/s requests, but sometimes the info is too confidential to be published to third party services.
The email solution is too side effecty. Also writing lambda involves writing code.
Connecting an SQS to inspect messages is causing me to create a special SQS just for testing...
Question:
Is there any option to submit to an SNS and to inspect the message in logs or something like that? Or am I limited only to this list? I'm talking only for dev purposes.

How do I (Can I) configure AWS SNS HTTP Request Timeout?

I'm sorry. This seems like a simple question, but I can't find the answer anywhere.
How do I configure the default http request timeout for an AWS SNS Topic. Ideally, I'd like to do this via the Java API (v1.11), but if I have to set it manually via the console, that's fine, too.
Thanks
If you're talking about the timeout for SNS to publish to the HTTP subscriber endpoint, it's hardcoded at 15 seconds: https://docs.aws.amazon.com/sns/latest/dg/sns-http-https-endpoint-as-subscriber.html

How to confirm a slack subscription to an aws SNS topic?

I have a lambda function that notifies an SNS topic.
It currently sends an email each time I invoke the function so the lambda, the SNS piece and the email subscription are all working ok.
Now I want a Slack Integration.
I've created a channel called aws_int but I can't get it to receive the notification.
I am stuck on the need to 'verify the subscription'. I don't see how I would do this in the https connection to slack.
I don't understand how to do it manually using the console in aws because all the documentation keeps referring to using the 'Subscription Confirmation URL'
I can't find what that is.
but I cannot find what that is.
I found a post talking about the JSON being invalid: Confirming AWS SNS Topic Subscription for Slack Webhook but I don't understand how I would use that, maybe I could use Postman but I am not sure exactly how to format that POST.
So how can I integrate Slack and aws for an SNS topic, specifically how can I do the confirmation (which is required in order to activate it). This has to be a common need!
If I use the hook URL I get
Everything I am trying is just stacking up more Pending Confirmations, which btw I cannot delete...
Here's my postman attempt...
You really DON'T need Lambda. Just SNS and SLACK are enough.
I found a way to integrate AWS SNS with slack WITHOUT AWS Lambda or AWS chatbot. With this approach you can confirm the subscription easily.
Follow the video which show all the step clearly.
https://www.youtube.com/watch?v=CszzQcPAqNM
Steps to follow:
Create slack channel or use existing channel
Create a work flow with selecting Webhook
Create a variable name as "SubscribeURL". The name
is very important
Add the above variable in the message body of the
workflow Publish the workflow and get the url
Add the above Url as subscription of the SNS You will see the subscription URL in the
slack channel
Follow the URl and complete the subscription
Come back to the work flow and change the "SubscribeURL" variable to "Message"
The publish the
message in SNS. you will see the message in the slack channel.
It doesn't look like there is a way to confirm an SNS subscription to a Slack endpoint (email, webhook, whatever). If you want to use SNS as a decoupling layer, you'll need to add a lambda into the system, which can handle the confirmation process.
Lambda -> webhook -> SNS -> Lambda -> webhook -> Slack
Confirming AWS SNS Topic Subscription for Slack Webhook has some more information about this.
I would recommend just using the Lambda to send a message to slack, either calling another dedicated lambda, or just internally to the original one. There's a good tutorial here. If you really want to use SNS, then you could use your original lambda to trigger SNS, then have a new slack-dedicated lambda subscribe to the SNS topic.