in source/lambda/services/customhelper/lib/index.js [305:348]
let sendResponse = function(
event,
callback,
logStreamName,
responseStatus,
responseData
) {
const responseBody = JSON.stringify({
Status: responseStatus,
Reason: `See the details in CloudWatch Log Stream: ${logStreamName}`,
PhysicalResourceId: `CustomResource-${event.LogicalResourceId}`,
StackId: event.StackId,
RequestId: event.RequestId,
LogicalResourceId: event.LogicalResourceId,
Data: responseData,
});
LOGGER.log('DEBUG', `RESPONSE BODY:\n ${responseBody}`);
const parsedUrl = url.parse(event.ResponseURL);
const options = {
hostname: parsedUrl.hostname,
port: 443,
path: parsedUrl.path,
method: 'PUT',
headers: {
'Content-Type': '',
'Content-Length': responseBody.length,
},
};
const req = https.request(options, res => {
LOGGER.log('INFO', `STATUS: ${res.statusCode}`);
LOGGER.log('DEBUG', `HEADERS: ${JSON.stringify(res.headers)}`);
callback(null, 'Successfully sent stack response!');
});
req.on('error', err => {
LOGGER.log('ERROR', `sendResponse Error:\n ${err}`);
callback(err);
});
req.write(responseBody);
req.end();
};