in bulkprovision/common/__init__.py [0:0]
def cfnresponse(event, context, responseStatus, responseData={}, physicalResourceId=None, noEcho=False):
responseBody = {}
responseBody['Status'] = responseStatus
responseBody['Reason'] = 'See the details in CloudWatch Log Stream: ' + context.log_stream_name
responseBody['PhysicalResourceId'] = physicalResourceId or context.log_stream_name
responseBody['StackId'] = event['StackId']
responseBody['RequestId'] = event['RequestId']
responseBody['LogicalResourceId'] = event['LogicalResourceId']
responseBody['NoEcho'] = noEcho
responseBody['Data'] = responseData
json_responseBody = json.dumps(responseBody)
headers = {'content-type' : '','content-length' : str(len(json_responseBody))}
try:
response = http.request('PUT',event['ResponseURL'],body=json_responseBody.encode('utf-8'),headers=headers)
logger.debug('Status code: ' + response.reason)
except Exception as e:
logger.error('send(..) failed executing requests.put(..): ' + str(e))