import urllib3
import json
import datetime
http = urllib3.PoolManager()
DIFF_JST_FROM_UTC = 9
def lambda_handler(event, context):
url = "xxx"
now = datetime.datetime.utcnow() + datetime.timedelta(hours=DIFF_JST_FROM_UTC)
theme_color_alert = "d700be"
theme_color_normal = "0076D7"
msg = {
"@type": "MessageCard",
"@context": "<http://schema.org/extensions",>
"themeColor": theme_color_normal,
"summary": "バッチ処理開始しました",
"sections": [{
"activityTitle": "バッチ処理定時実行",
"activityImage": "http://xxx"
"facts": [
{
"name": "時間",
"value": now.strftime('%Y年%m月%d日 %H:%M:%S')
}, {
"name": "メッセージ",
"value": "バッチ処理が開始になりました"
}],
"markdown": "true"
}]
}
encoded_msg = json.dumps(msg).encode('utf-8')
resp = http.request('POST',url, body=encoded_msg)