in src/main/resources/cdk_custom_resources/create_deployment_group.py [0:0]
def send(event, context, response_status, response_data, physical_resource_id=None, no_echo=False):
response_url = event['ResponseURL']
LOGGER.info(response_url)
response_body = {
'Status': response_status,
'Reason': 'See the details in CloudWatch Log Stream: ' + context.log_stream_name,
'PhysicalResourceId': physical_resource_id or context.log_stream_name, 'StackId': event['StackId'],
'RequestId': event['RequestId'], 'LogicalResourceId': event['LogicalResourceId'],
'NoEcho': no_echo,
'Data': response_data
}
json_response_body = json.dumps(response_body)
LOGGER.info("Response body:\n" + json_response_body)
headers = {
'content-type': '',
'content-length': str(len(json_response_body))
}
try:
req = urllib.request.Request(response_url,
data=json_response_body.encode('utf-8'),
headers=headers,
method='PUT')
response = urllib.request.urlopen(req)
LOGGER.info("Status code: " + response.reason)
except Exception as e:
LOGGER.error("send(..) failed executing requests.put(..): " + str(e))