Amazon CloudFront
Developer Guide (API Version 2016-09-29)

Updating HTTP Responses in an Origin-Response Trigger

When CloudFront receives an HTTP response from the origin server, if there is an origin-response trigger associated with the cache behavior, you can modify the HTTP response to override what was returned from the origin.

Some common scenarios for updating HTTP responses include the following:

You can also replace the HTTP responses in viewer and origin request events. For more information, see Generating HTTP Responses in Request Triggers.

When you’re working with the HTTP response, note that Lambda@Edge does not expose the HTML body that is returned by the origin server to the origin-response trigger. You can generate a static content body by setting it to the desired value, or remove the body inside the function by setting the value to be empty. If you don’t update the body field in your function, the original body returned by the origin server is returned back to viewer.