Python botocore.vendored.requests.put() Examples
The following are 30
code examples of botocore.vendored.requests.put().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
botocore.vendored.requests
, or try the search function
.
Example #1
Source File: request.py From iopipe-python with Apache License 2.0 | 6 votes |
def upload_profiler_report(url, filename, config): """ Uploads a profiler report to IOpipe :param url: The signed URL :param filename: The profiler report file :param config: The IOpipe config """ try: logger.debug("Uploading profiler report to IOpipe") with open(filename, "rb") as data: response = requests.put(url, data=data, timeout=config["network_timeout"]) response.raise_for_status() except Exception as e: logger.debug("Error while uploading profiler report: %s", e) if hasattr(e, "response"): logger.debug(e.response.content) else: logger.debug("Profiler report uploaded successfully") finally: if os.path.isfile(filename): os.remove(filename)
Example #2
Source File: Routetable.py From aws-cloudformation-templates with Apache License 2.0 | 6 votes |
def send(event, context, responseStatus, responseData, physicalResourceId=None, noEcho=False): responseUrl = event['ResponseURL'] print(responseUrl) responseBody = {'Status': responseStatus, 'Reason': 'See the details in CloudWatch Log Stream: ' + context.log_stream_name, 'PhysicalResourceId': physicalResourceId or context.log_stream_name, 'StackId': event['StackId'], 'RequestId': event['RequestId'], 'LogicalResourceId': event['LogicalResourceId'], 'Data': responseData} json_responseBody = json.dumps(responseBody) print("Response body:\n" + json_responseBody) headers = { 'content-type' : '', 'content-length' : str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print("Status code: " + response.reason) except Exception as e: print("send(..) failed executing requests.put(..): " + str(e))
Example #3
Source File: resource_tools.py From speke-reference-server with Apache License 2.0 | 6 votes |
def send(event, context, response_status, response_data, physical_resource_id): response_url = event['ResponseURL'] 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'], 'Data': response_data } json_response_body = json.dumps(response_body) print("Response body:\n" + json_response_body) headers = {'content-type': '', 'content-length': str(len(json_response_body))} try: response = requests.put(response_url, data=json_response_body, headers=headers) print("Status code: " + response.reason) except Exception as e: print("EXCEPTION {}".format(e)) return
Example #4
Source File: lambda_function.py From aws-cloudformation-templates with Apache License 2.0 | 6 votes |
def sendResponse(event, context, responseStatus, responseData, reason=None, physical_resource_id=None): responseBody = {'Status': responseStatus, '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'], 'Data': responseData} print 'RESPONSE BODY:n' + json.dumps(responseBody) responseUrl = event['ResponseURL'] json_responseBody = json.dumps(responseBody) headers = { 'content-type' : '', 'content-length' : str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print "Status code: " + response.reason except Exception as e: print "send(..) failed executing requests.put(..): " + str(e)
Example #5
Source File: utils.py From aws-deployment-framework with Apache License 2.0 | 6 votes |
def _send_response(response_url, response_body, put=requests.put): try: json_response_body = json.dumps(response_body) except Exception as e: msg = "Failed to convert response to json: {}".format(str(e)) logger.error(msg, exc_info=True) response_body = {'Status': 'FAILED', 'Data': {}, 'Reason': msg} json_response_body = json.dumps(response_body) logger.debug("CFN response URL: {}".format(response_url)) logger.debug(json_response_body) headers = {'content-type': '', 'content-length': str(len(json_response_body))} while True: try: response = put(response_url, data=json_response_body, headers=headers) logger.info("CloudFormation returned status code: {}".format(response.reason)) break except Exception as e: logger.error("Unexpected failure sending response to CloudFormation {}".format(e), exc_info=True) time.sleep(5)
Example #6
Source File: lambda_function.py From aws-cloudformation-templates with Apache License 2.0 | 6 votes |
def sendResponse(event, context, responseStatus, responseData, reason=None, physical_resource_id=None): responseBody = {'Status': responseStatus, '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'], 'Data': responseData} print 'RESPONSE BODY:n' + json.dumps(responseBody) responseUrl = event['ResponseURL'] json_responseBody = json.dumps(responseBody) headers = { 'content-type' : '', 'content-length' : str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print "Status code: " + response.reason except Exception as e: print "send(..) failed executing requests.put(..): " + str(e)
Example #7
Source File: cfnresponse.py From quickstart-git2s3 with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId): responseUrl = event['ResponseURL'] print responseUrl 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['Data'] = responseData json_responseBody = json.dumps(responseBody) print "Response body:\n" + json_responseBody headers = { 'content-type' : '', 'content-length' : str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print "Status code: " + response.reason except Exception as e: print "send(..) failed executing requests.put(..): " + str(e)
Example #8
Source File: LambdaRDS_CFNInit.py From aws-lambda-manage-rds-connections with Apache License 2.0 | 5 votes |
def sendResponse(event, context, responseStatus, responseData, physicalResourceId): responseUrl = event['ResponseURL'] # print responseUrl responseBody = {} responseBody['Status'] = responseStatus responseBody['Reason'] = 'See the details in CloudWatch Log Stream: ' + \ context.log_stream_name responseBody['PhysicalResourceId'] = context.log_stream_name responseBody['StackId'] = event['StackId'] responseBody['RequestId'] = event['RequestId'] responseBody['LogicalResourceId'] = event['LogicalResourceId'] responseBody['Data'] = responseData json_responseBody = json.dumps(responseBody) print ("Response body:\n" + json_responseBody) headers = { 'content-type': '', 'content-length': str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print ("Status code: " + response.reason) except Exception as e: print ("send(..) failed executing requests.put(..): " + str(e))
Example #9
Source File: index.py From cli2cloudformation with Apache License 2.0 | 5 votes |
def send_cfn_response(event, context, response_status, response_data, reason): response_body = {'Status': response_status, 'Reason': 'Log stream name: ' + context.log_stream_name, 'PhysicalResourceId': context.log_stream_name, 'StackId': event['StackId'], 'RequestId': event['RequestId'], 'LogicalResourceId': event['LogicalResourceId'], 'Data': response_data} print("Log Reason: " + reason) try: requests.put(event['ResponseURL'], data=json.dumps(response_body)) except Exception as e: print(e) raise
Example #10
Source File: get-password-lambda.py From rds-starter-templates with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId=None, noEcho=False): responseUrl = event['ResponseURL'] print(responseUrl) 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 = requests.put(responseUrl, data=json_responseBody, headers=headers) print("Status code - " + response.reason) except Exception as e: print("send(..) failed executing requests.put(..) -" + str(e))
Example #11
Source File: generate-password-lambda.py From rds-starter-templates with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId=None, noEcho=False): responseUrl = event['ResponseURL'] print(responseUrl) 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) print("Response body:\n" + json_responseBody) headers = { 'content-type' : '', 'content-length' : str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print("Status code: " + response.reason) except Exception as e: print("send(..) failed executing requests.put(..): " + str(e))
Example #12
Source File: get-password-lambda.py From rds-starter-templates with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId=None, noEcho=False): responseUrl = event['ResponseURL'] print(responseUrl) 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 = requests.put(responseUrl, data=json_responseBody, headers=headers) print("Status code - " + response.reason) except Exception as e: print("send(..) failed executing requests.put(..) -" + str(e))
Example #13
Source File: generate-password-lambda.py From rds-starter-templates with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId=None, noEcho=False): responseUrl = event['ResponseURL'] print(responseUrl) 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) print("Response body:\n" + json_responseBody) headers = { 'content-type' : '', 'content-length' : str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print("Status code: " + response.reason) except Exception as e: print("send(..) failed executing requests.put(..): " + str(e))
Example #14
Source File: get-password-lambda.py From rds-starter-templates with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId=None, noEcho=False): responseUrl = event['ResponseURL'] print(responseUrl) 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 = requests.put(responseUrl, data=json_responseBody, headers=headers) print("Status code - " + response.reason) except Exception as e: print("send(..) failed executing requests.put(..) -" + str(e))
Example #15
Source File: index.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId=None, noEcho=False): responseUrl = event['ResponseURL'] print(responseUrl) 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) print("Response body:\n" + json_responseBody) headers = { 'content-type' : '', 'content-length' : str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print("Status code: " + response.reason) except Exception as e: print("send(..) failed executing requests.put(..): " + str(e))
Example #16
Source File: cfnresponse.py From quickstart-git2s3 with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId): responseUrl = event['ResponseURL'] print responseUrl 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['Data'] = responseData json_responseBody = json.dumps(responseBody) print "Response body:\n" + json_responseBody headers = { 'content-type' : '', 'content-length' : str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print "Status code: " + response.reason except Exception as e: print "send(..) failed executing requests.put(..): " + str(e)
Example #17
Source File: lambdas.py From quickstart-datalake-47lining with Apache License 2.0 | 5 votes |
def send_cfnresponse(event, context, response_status, data: dict): response_url = event['ResponseURL'] print('CFN response url: {}'.format(response_url)) response_body = {} response_body['Status'] = response_status response_body['Reason'] = 'See the details in CloudWatch Log Stream: ' + context.log_stream_name response_body['PhysicalResourceId'] = context.log_stream_name response_body['StackId'] = event['StackId'] response_body['RequestId'] = event['RequestId'] response_body['LogicalResourceId'] = event['LogicalResourceId'] response_body['Data'] = data json_response = json.dumps(response_body) print("Response body:\n" + json_response) headers = { 'content-type': '', 'content-length': str(len(json_response)) } try: response = requests.put(response_url, data=json_response, headers=headers) print("Status code: " + response.reason) except Exception as e: print("send(..) failed executing requests.put(..): " + str(e))
Example #18
Source File: cfnresponse.py From quickstart-redhat-openshift with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId, reason=None): responseUrl = event['ResponseURL'] print responseUrl responseBody = {} responseBody['Status'] = responseStatus if reason: responseBody['Reason'] = reason else: 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['Data'] = responseData json_responseBody = json.dumps(responseBody) print "Response body:\n" + json_responseBody headers = { 'content-type' : '', 'content-length' : str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print "Status code: " + response.reason except Exception as e: print "send(..) failed executing requests.put(..): " + str(e)
Example #19
Source File: cfnresponse.py From quickstart-redhat-openshift with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId): responseUrl = event['ResponseURL'] print responseUrl 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['Data'] = responseData json_responseBody = json.dumps(responseBody) print "Response body:\n" + json_responseBody headers = { 'content-type' : '', 'content-length' : str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print "Status code: " + response.reason except Exception as e: print "send(..) failed executing requests.put(..): " + str(e)
Example #20
Source File: service.py From quickstart-redhat-openshift with Apache License 2.0 | 5 votes |
def send_response(event, context, response_status, response_data): response_body = {'Status': response_status, 'StackId': event['StackId'], 'RequestId': event['RequestId'], 'PhysicalResourceId': context.log_stream_name, 'Reason': 'For details see AWS CloudWatch LogStream: ' + context.log_stream_name, 'LogicalResourceId': event['LogicalResourceId'], 'Data': response_data} request = requests.put(event['ResponseURL'], data=json.dumps(response_body)) if request.status_code != 200: print(request.text) raise Exception('Error detected in [CFN RESPONSE != 200.')
Example #21
Source File: cfnresponse.py From quickstart-redhat-openshift with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId, reason=None): responseUrl = event['ResponseURL'] print responseUrl responseBody = {} responseBody['Status'] = responseStatus if reason: responseBody['Reason'] = reason else: 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['Data'] = responseData json_responseBody = json.dumps(responseBody) print "Response body:\n" + json_responseBody headers = { 'content-type' : '', 'content-length' : str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print "Status code: " + response.reason except Exception as e: print "send(..) failed executing requests.put(..): " + str(e)
Example #22
Source File: ami.py From cloudformation-ami with MIT License | 5 votes |
def send(event, log_stream_name, responseStatus, responseData, physicalResourceId, reason=None): responseUrl = event['ResponseURL'] print(f'responseUrl: {responseUrl}') responseBody = {} responseBody['Status'] = responseStatus responseBody['Reason'] = reason if reason else 'See the details in CloudWatch Log Stream: ' + log_stream_name responseBody['PhysicalResourceId'] = physicalResourceId responseBody['StackId'] = event['StackId'] responseBody['RequestId'] = event['RequestId'] responseBody['LogicalResourceId'] = event['LogicalResourceId'] responseBody['Data'] = responseData json_responseBody = json.dumps(responseBody) print("Response body:\n" + json_responseBody) headers = { 'content-type': '', 'content-length': str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print("Status code: " + response.reason) except Exception as e: print("send(..) failed executing requests.put(..): " + str(e))
Example #23
Source File: cfnresponse.py From connect-integration-examples with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId): responseUrl = event['ResponseURL'] print responseUrl 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['Data'] = responseData json_responseBody = json.dumps(responseBody) print "Response body:\n" + json_responseBody headers = { 'content-type': '', 'content-length': str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print "Status code: " + response.reason except Exception as e: print "send(..) failed executing requests.put(..): " + str(e)
Example #24
Source File: index-custom-resource.py From aws-media-services-vod-automation with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId): responseUrl = event['ResponseURL'] responseBody = { 'Status': responseStatus, 'Reason': 'See the details in CloudWatch Log Stream: ' + context.log_stream_name, 'PhysicalResourceId': physicalResourceId or context.log_stream_name, 'StackId': event['StackId'], 'RequestId': event['RequestId'], 'LogicalResourceId': event['LogicalResourceId'], 'Data': responseData } json_responseBody = json.dumps(responseBody) print("Response body:\n" + json_responseBody) headers = { 'content-type': '', 'content-length': str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print("Status code: " + response.reason) except Exception as e: print("send(..) failed executing requests.put(..): " + str(e)) return
Example #25
Source File: request.py From iopipe-python with Apache License 2.0 | 5 votes |
def upload_log_data(url, stream_or_file, config): """ Uploads log data to IOpipe. :param url: The signed URL :param stream_or_file: The log data stream or file :param config: The IOpipe config """ try: logger.debug("Uploading log data to IOpipe") if isinstance(stream_or_file, StringIO): stream_or_file.seek(0) response = requests.put( url, data=stream_or_file, timeout=config["network_timeout"] ) else: with open(stream_or_file, "rb") as data: response = requests.put( url, data=data, timeout=config["network_timeout"] ) response.raise_for_status() except Exception as e: logger.debug("Error while uploading log data: %s", e) logger.exception(e) if hasattr(e, "response") and hasattr(e.response, "content"): logger.debug(e.response.content) else: logger.debug("Log data uploaded successfully") finally: if isinstance(stream_or_file, str) and os.path.exists(stream_or_file): os.remove(stream_or_file)
Example #26
Source File: clientvpnendpoint-customlambdaresource.py From quickstart-biotech-blueprint with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId=None, noEcho=False): responseUrl = event['ResponseURL'] 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 = requests.put(responseUrl, data=json_responseBody, headers=headers) except Exception as e: error = e
Example #27
Source File: resource_tools.py From aws-media-services-simple-live-workflow with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId): responseUrl = event['ResponseURL'] responseBody = { 'Status': responseStatus, 'Reason': 'See the details in CloudWatch Log Stream: ' + context.log_stream_name, 'PhysicalResourceId': physicalResourceId or context.log_stream_name, 'StackId': event['StackId'], 'RequestId': event['RequestId'], 'LogicalResourceId': event['LogicalResourceId'], 'Data': responseData } json_responseBody = json.dumps(responseBody) print("Response body:\n" + json_responseBody) headers = { 'content-type': '', 'content-length': str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print("Status code: " + response.reason) except Exception as e: print("send(..) failed executing requests.put(..): " + str(e)) return
Example #28
Source File: cfnresponse.py From aws-servicebroker with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId, reason=None): responseUrl = event['ResponseURL'] print(responseUrl) responseBody = {} responseBody['Status'] = responseStatus responseBody['Reason'] = reason or '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['Data'] = responseData json_responseBody = json.dumps(responseBody) print("Response body:\n" + json_responseBody) headers = { 'content-type': '', 'content-length': str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print("Status code: " + response.reason) except Exception as e: print("send(..) failed executing requests.put(..): " + str(e))
Example #29
Source File: cfnresponse.py From aws-servicebroker with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId, reason=None): responseUrl = event['ResponseURL'] print(responseUrl) responseBody = {} responseBody['Status'] = responseStatus responseBody['Reason'] = reason or '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['Data'] = responseData json_responseBody = json.dumps(responseBody) print("Response body:\n" + json_responseBody) headers = { 'content-type': '', 'content-length': str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print("Status code: " + response.reason) except Exception as e: print("send(..) failed executing requests.put(..): " + str(e))
Example #30
Source File: cfnresponse.py From aws-servicebroker with Apache License 2.0 | 5 votes |
def send(event, context, responseStatus, responseData, physicalResourceId, reason=None): responseUrl = event['ResponseURL'] print(responseUrl) responseBody = {} responseBody['Status'] = responseStatus responseBody['Reason'] = reason or '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['Data'] = responseData json_responseBody = json.dumps(responseBody) print("Response body:\n" + json_responseBody) headers = { 'content-type': '', 'content-length': str(len(json_responseBody)) } try: response = requests.put(responseUrl, data=json_responseBody, headers=headers) print("Status code: " + response.reason) except Exception as e: print("send(..) failed executing requests.put(..): " + str(e))