@@ -231,7 +231,7 @@ public void processRequest(final InputStream inputStream, final OutputStream out
231
231
} finally {
232
232
// A response will be output on all paths, though CloudFormation will
233
233
// not block on invoking the handlers, but rather listen for callbacks
234
- writeResponse (outputStream , handlerResponse );
234
+ writeResponse (outputStream , handlerResponse , request );
235
235
publishExceptionCodeAndCountMetrics (request == null ? null : request .getAction (), handlerResponse .getErrorCode ());
236
236
}
237
237
}
@@ -372,7 +372,9 @@ public void processRequest(final InputStream inputStream, final OutputStream out
372
372
373
373
}
374
374
375
- protected void writeResponse (final OutputStream outputStream , final ProgressEvent <ResourceT , CallbackT > response )
375
+ protected void writeResponse (final OutputStream outputStream ,
376
+ final ProgressEvent <ResourceT , CallbackT > response ,
377
+ final HandlerRequest <ResourceT , CallbackT > request )
376
378
throws IOException {
377
379
if (response .getResourceModel () != null ) {
378
380
// strip write only properties on final results, we will need the intact model
@@ -383,10 +385,21 @@ protected void writeResponse(final OutputStream outputStream, final ProgressEven
383
385
}
384
386
385
387
String output = this .serializer .serialize (response );
388
+ if (response .getStatus () != OperationStatus .IN_PROGRESS ) {
389
+ // if status is not IN_PROGRESS, it means the response has been sanitized
390
+ final String logicalResourceId = getLogicalResourceId (request );
391
+ final String stackId = getStackId (request );
392
+ this .log (String .format ("StackId=%s LogicalResourceId=%s Response=%s" , stackId , logicalResourceId , output ));
393
+ }
386
394
outputStream .write (output .getBytes (StandardCharsets .UTF_8 ));
387
395
outputStream .flush ();
388
396
}
389
397
398
+ protected void writeResponse (final OutputStream outputStream , final ProgressEvent <ResourceT , CallbackT > response )
399
+ throws IOException {
400
+ this .writeResponse (outputStream , response , null );
401
+ }
402
+
390
403
protected ResourceT sanitizeModel (final ResourceT model ) throws IOException {
391
404
// strip write only properties on final results, we will need the intact model
392
405
// while provisioning
@@ -570,6 +583,15 @@ protected String getStackId(final HandlerRequest<ResourceT, CallbackT> request)
570
583
return null ;
571
584
}
572
585
586
+ @ VisibleForTesting
587
+ protected String getLogicalResourceId (final HandlerRequest <ResourceT , CallbackT > request ) {
588
+ if (request != null && request .getRequestData () != null ) {
589
+ return request .getRequestData ().getLogicalResourceId ();
590
+ }
591
+
592
+ return null ;
593
+ }
594
+
573
595
private void replaceInMap (final Map <String , String > targetMap , final Map <String , String > sourceMap ) {
574
596
if (targetMap == null ) {
575
597
return ;
0 commit comments