何かのイベントにフックしてlambdaを実行する際、eventの中身がわからくて困ったとき用メモ
import json
import urllib.request
def post_slack(message):
send_data = {
"text": message,
}
send_text = json.dumps(send_data)
request = urllib.request.Request(
'slackのwebhookURL',
data = send_text.encode('utf-8'),
method = "POST"
)
with urllib.request.urlopen(request) as response:
response_body = response.read().decode('utf-8')
def lambda_handler(event, context):
message = json.dumps(event)
post_slack(message)