feat(hos_client_create, hos_client_destory): 多次调用destory不会导致重复释放

This commit is contained in:
彭宣正
2020-12-14 17:24:58 +08:00
parent 505d529c32
commit 10b370e486
55976 changed files with 8544395 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
# Whenever you make any change here, you should update it in Amazon S3.
# In binary release pipeline, build jobs will send the results to a SNS topic.
# And this lambda function, triggered by this SNS notifications, will send messages about the build results to a Chime room.
# Other functionality could be added in the future, like put metrics to CloudWatch or trigger another alarm.
import boto3
import json
import os
from botocore.vendored import requests
chime_bot_url = os.environ['CHIME_BOT_URL']
def lambda_handler(event, context):
print(event)
message = event["Records"][0]["Sns"]["Message"]
headers = {'Content-Type': 'application/json'}
data = {}
if "FAILURE" in message:
# @All Members if build failed.
# Will convert '/md [message]' to '/md @All[message]'
firstSpaceIndex = message.find(' ')
message = message[:firstSpaceIndex+1] + '@All' + message[firstSpaceIndex+1:]
make_request = True
elif 'SUCCESS' in message:
make_request = True
if make_request == True:
data["Content"] = message
r = requests.post(chime_bot_url, headers = headers, data = json.dumps(data))
return r.reason
else:
return 0