Created
December 6, 2023 02:21
-
-
Save kennethphough/f064e5406d793cf3022166d7266cfdcd to your computer and use it in GitHub Desktop.
Python-based Lambda function for sending SNS notifications to MS Teams
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
import requests | |
def lambda_handler(event, context): | |
msg = {'text': event['Records'][0]['Sns']['Message']} | |
headers = {'Content-Type': 'application/json'} | |
response = requests.post(os.environ['TEAMS_WEBHOOK_URL'], headers=headers, data=json.dumps(msg).encode('utf-8')) | |
return { | |
'statusCode': 200, | |
'body': "Teams message sent!" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment