in automation/lambda/handlers/index.py [0:0]
def send(event, context, response_status, response_data, physical_resource_id=None, no_echo=False, reason=None):
responseUrl = event['ResponseURL']
logger.info(responseUrl)
response_body = {
'Status': response_status,
'Reason': reason or "See the details in CloudWatch Log Stream",
'PhysicalResourceId': physical_resource_id,
'StackId': event['StackId'],
'RequestId': event['RequestId'],
'LogicalResourceId': event['LogicalResourceId'],
'NoEcho': no_echo,
'Data': response_data
}
json_response_body = json.dumps(response_body)
logger.info(json_response_body)
headers = {
'content-type': '',
'content-length': str(len(json_response_body))
}
try:
response = http.request('PUT', responseUrl, headers=headers, body=json_response_body)
logger.info(f"Status code: {response.status}")
except Exception as e:
logger.info("send(..) failed executing http.request(..):", e)