def send_response()

in deployment_lambda/lambda_function.py [0:0]


def send_response(request, response, status=None, reason=None):
    """ Send our response to the pre-signed URL supplied by CloudFormation
    If no ResponseURL is found in the request, there is no place to send a
    response. This may be the case if the supplied event was for testing.
    """

    if status is not None:
        response['Status'] = status

    if reason is not None:
        response['Reason'] = reason

    logger.info((json.dumps(response)))

    if 'ResponseURL' in request and request['ResponseURL']:
        url = urllib.parse.urlparse(request['ResponseURL'])
        body = json.dumps(response)
        https = http.client.HTTPSConnection(url.hostname)
        https.request('PUT', url.path + '?' + url.query, body)

    return response