Skip to content

Instantly share code, notes, and snippets.

@kennethphough
Created December 6, 2023 02:21
Show Gist options
  • Save kennethphough/f064e5406d793cf3022166d7266cfdcd to your computer and use it in GitHub Desktop.
Save kennethphough/f064e5406d793cf3022166d7266cfdcd to your computer and use it in GitHub Desktop.
Python-based Lambda function for sending SNS notifications to MS Teams
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