Sunday, February 25, 2024

AWS CF policy workflow

 


As outlined in the above diagram, response headers policies do not impact the origin-supplied headers stored in CloudFront’s caching layers. 

Headers configured in the policies are inserted after the response leaves the cache, and before the viewer response event that triggers a function if configured. 

If you have an edge function attached to the same behavior, policy inserted headers will be accessible in your function through the event object listing all the headers associated with the response. 

You can use that functionality by treating the headers generated through a policy as inputs for the function that will impact how the code is executed. This is similar to using environmental variables.

2 comments:

  1. The distinction between origin-supplied headers and policy-inserted headers is something I struggled with early on. Seeing how policies can feed into functions makes me wonder about best practices for logging and monitoring headers in AWS—any tips on that?

    ReplyDelete