+1
+1
+1
+1
+1
If you are a Cloud Administrator, System Engineer, Security Administrations, Governance Team, or IT Manager then this is a post for you.
As a leading Cloud provider, AWS can be scaled to millions of requests to your servers. Monitoring is everything to keep you secure, from malicious activities that can be impacted to your Comapny.
Your company might use MS teams as your first point for notification APP or a team channel. In such situations, you need to send notifications to the team’s channel.
Consider Sernarios like :-
Today you will be learning two ways to implement a solution for such scenarios.
1.Directly to Microsoft Teams
2.Using lambda and webhook
Setup and forget, An out-of-the-box idea came into my mind.
Step One
Get email of your channel
Consider this email as a notification end-point
Step two
Now copy that email & go to SNS and subscribe to that email, and confirm the subscription from your Chat room.
Step Three
Now Click and confirm the subscription.
Congratulations you have successfully configured, Now let’s test it. Go to your Topic and Click Publish message . Now give a subject name and a message and click Publish Message
tadaaaaaaaaa…………………..
AWS Services Used
a) Let’s get the Webhook from Microsoft Teams.
Goto your channel , click on to three dots and click connectors.
Search and install Incoming Webhook and click configure.
Now you can Name your Webhook and upload a logo if necessary and Click create.
A webhook URL will be prompted, make a note of it
b) Let’s create a lambda function.
Name your Lambda Function and select latest python version and click Create Function
Once you have created lamda function
Copy this code to lambda function or get it from the github . Replace the default url with your webhook url. Also Make a note of Lambda function ARN
#!/usr/bin/python3.8
import urllib3
import json
http = urllib3.PoolManager()
def lambda_handler(event, context):
url = “your webhook url”
msg = {
“text”: event[‘Records’][0][‘Sns’][‘Message’]
}
encoded_msg = json.dumps(msg).encode(‘utf-8’)
resp = http.request(‘POST’,url, body=encoded_msg)
print({
“message”: event[‘Records’][0][‘Sns’][‘Message’],
“status_code”: resp.status,
“response”: resp.data
})
Now click Deploy. you will be able to see
C) Now let’s configure SNS
Goto your SNS tops and click to Create Subscription
Select your Protocol as Lambda and Paste ARN of your Lambda and Now Click Create subscription
Congratulations you have successfully configured, Now let’s test it. Go to your Topic and Click Publish message . Now give a subject name and a message and click Publish Message
Now Check your Teams Channel , you will be able to see the SNS message.
Congratulations.
Share on