How to send SSM (Agent) status notification to SNS within AWS - amazon-web-services

My question is
Is there any other way to monitor the SSM status and send the event notification to SNS instead of configuring the SNS Topic from the executor by providing NotificationConfig ?
I encounter a scenario where within our staging environment, there is an SNS top with a subscription that can always receive the SSM(systems manager) status notification, and it will trigger a lambda function to send notifications to our Slack App. Was done by our previous colleague.
However, within our production environment, I can't set up such a topic that can always receive the SSM status notification.
Within the staging, the SSM agent is triggered through a python lambda function. It sends commands with the PowerShell script without configuring the NotificationConfig argument. I wonder how this event is sent to the SNS topic.
I follow AWS' documentation which assigns the SNS Topic to the executor of the command. I know this way. (https://docs.aws.amazon.com/systems-manager/latest/userguide/monitoring-sns-rc-send.html)
Many Thanks.

You can capture any AWS event using EventBridge.

Related

GCP Deployment manager - Call HTTP endpoint when everything is deployed

I have a template that creates a few resources in GCP, and I want it to either call an HTTP endpoint or publish a message to a topic whenever the deployment completes. I've been checking different services all day, and couldn't find anything about it.
In AWS, it is quite easy to deploy an SNS message that is published to an SNS topic, which is subscribed to SQS Queue, and that triggers a lambda function. In Azure ARM templates, we can use az CLI to invoke a web request and call an endpoint directly.
I couldn't find any similar in GCP. Is there any way of either calling an HTTP endpoint, Cloud Function or perhaps publishing a message to a topic whenever a deployment is finished?
I really appreciate any help.
The best approach in GCP is to Create a Logging Sink using a filter and the Logging query language to only send the Deployment Manager logs to a PubSub topic.
Here is an example of a sink sending deployment manager logs to a PubSub topic previously created:
gcloud logging sinks create $SINK_NAME pubsub.googleapis.com/projects/$YOUR_PROJECT/topics/$TOPIC \
--log-filter='resource.type="deployment"' --description="my sink"
Be careful to Set the destination permissions or will not see the logs in the PubSub topic.
Once you are getting the logs in the PubSub topic, you can configure Cloud Pub/Sub Triggers to fire up an HTTP call based on content of the log.

AWS AppConfig flags with SNS Topics

I've set up an AWS SNS Service that sends an email to a specific address and calls a webhook to notify an external application that a job is completed.
I've been asked to enable/disable one of the two subscriptions based on a flag that I've set inside AWS AppConfig. I've googled around but have found no way of conditioning the execution of such subscription based on the value of the flag, is this possible?
Should I use a lambda as a subscription endpoint then send the webhook/mail based on AWS config flag value?
You cannot directly tie a SNS subscription status to a flag in AppConfig.
What you can do is either to read the flag before publishing the message to SNS or, as you said, replace the subscription with a Lambda that checks the flag after receiving a message from the SNS topic.

Use External Notifier in AWS with SNS

I am using AWS with Codedeploy and Codepipeline, with Git to push our PHP codes and I want to use Discord or any free service to Notify our Pipeline status
EventBridge service provide codepipeline notification. Trigger it to SNS for email notification or lambda function for custom action
Available EventBridge event for codepipeline:
https://docs.aws.amazon.com/codepipeline/latest/userguide/detect-state-changes-cloudwatch-events.html
Telegram notification python example (you can try other application API)
https://levelup.gitconnected.com/simple-telegram-bot-with-python-and-aws-lambda-5eab1066b466

AWS RDS event subscription with lambda in another account

I am trying to get lambda in another account to get it invoked by RDS instance event notifications.
RDS event subscription is set to invoke SNS topic which triggers lambda in other account.
I have setup an entire stack using cloudformation. Things I achieved so far are
RDS events are able to invoke SNS topic, I have tested it using creating email subscription to SNS topic
SNS topic is able to trigger lambda in another account. I have tested it using publish messages in SNS topic. I can see that is flowing through in cloudwatch logs.
Part I am not able to get working is, RDS events triggering SNS and then Lamba in other account. Its very strage as individual bits are working fine but not end to end. Other observation is status of the SNS subscription in RDS events is shown as Active and I can see subscription log in lambda but nothing happens after I reboot RDS instance to test.
Also, I see this bizzare behaviour that subscription status is set to Null.
I followed below links for reference
https://jimmythompson.co.uk/blog/sns-and-lambda/
https://medium.com/pablo-perez/infrastructure-as-a-code-should-not-be-imperative-43d9a64e3998
Is there something I am missing? Any help is much appreciated.

AWS - Send Scheduled Events notifications with text message or HipChat message

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