in TerraformCustomResourceHandler/src/main/java/com/amazon/servicecatalog/terraform/customresource/ResponsePoster.java [54:77]
private static void postResponse(String responseUrl,
CustomResourceResponse response) {
try {
HttpPut putRequest = new HttpPut(responseUrl);
// Need to suppress Content-Type or S3 would give a 403 invalid signature response.
putRequest.setHeader("Content-Type", null);
String serializedResponse = CustomResourceMarshaller.write(response);
log.info("Posting response: " + serializedResponse);
putRequest.setEntity(new StringEntity(serializedResponse));
HttpResponse httpResponse = httpClient.execute(putRequest);
int statusCode = httpResponse.getStatusLine().getStatusCode();
if (statusCode != 200) {
throw new RuntimeException(String.format(
"Received status code %d when posting response at URL %s to CloudFormation. Entire message: %s.",
statusCode, responseUrl, httpResponse));
}
} catch (IOException e) {
String message = "Unable to post response to URL " + responseUrl + " to CloudFormation";
log.error(message, e);
throw new RuntimeException(message, e);
}
}