/some-path/some-page
: origin 1 (web app)/some-path/other-page
: origin 2 (CMS)No logical pattern to differentiate paths
In other words; origin 2 pages should only display if the page is not present in origin 1.
r = requests.head(f"https://{hostname}{path}", headers=formatted_headers, params=params, timeout=1)
If you want the function to execute for every request that CloudFront receives for the distribution, use the viewer request or viewer response events. Origin request and origin response events occur only when a requested object isn’t cached in an edge location and CloudFront forwards a request to the origin.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-how-to-choose-event.html
inheritance_pages = [
"/my-page",
"/my-page/nested-page",
"/other-page",
]
if path in inheritance_pages:
logging.info(f"Path {path} is included in list of pages used in CMS for inheritance purposes, leaving origin as-is.")
return request
/aws/lambda/us-east-1
in the region closest to your edge location/aws/cloudfront/LambdaEdge