in source/helper/website_helper.py [0:0]
def send_response(event, context, response_status, response_data):
"""
Send a resource manipulation status response to CloudFormation
"""
response_body = json.dumps({
"Status": response_status,
"Reason": "See the details in CloudWatch Log Stream: " + context.log_stream_name,
"PhysicalResourceId": context.log_stream_name,
"StackId": event['StackId'],
"RequestId": event['RequestId'],
"LogicalResourceId": event['LogicalResourceId'],
"Data": response_data
})
LOGGER.info('ResponseURL: {s}'.format(s=event['ResponseURL']))
LOGGER.info('ResponseBody: {s}'.format(s=response_body))
opener = build_opener(HTTPHandler)
request = Request(event['ResponseURL'], data=response_body.encode('utf-8'))
request.add_header('Content-Type', '')
request.add_header('Content-Length', len(response_body))
request.get_method = lambda: 'PUT'
response = opener.open(request)
LOGGER.info("Status code: {s}".format(s=response.getcode))
LOGGER.info("Status message: {s}".format(s=response.msg))