Skip to content

Instantly share code, notes, and snippets.

@sanju2
Created March 3, 2022 19:08
Show Gist options
  • Save sanju2/7d8cd82688aef8a6248d83abef35416a to your computer and use it in GitHub Desktop.
Save sanju2/7d8cd82688aef8a6248d83abef35416a to your computer and use it in GitHub Desktop.
import urllib3
import json
http = urllib3.PoolManager()
def lambda_handler(event, context):
url = ""
msg = {
"channel": "",
"username": "WEBHOOK_USERNAME",
"text": event['Records'][0]['Sns']['Message'],
"icon_emoji" : ""
}
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
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment