How it works...

This recipe builds on the Deploying a service behind a CDN recipe. The main difference in this recipe is that we have multiple Origins and multiple CacheBehaviors, one each for our Bucket and our ApiGatewayRestApi. We use the DefaultCacheBehavior for our S3Origin, because we could store many different business domains in the bucket with different paths. Conversely, there is a single PathPattern (/search) that needs to be directed to our APIGateway origin, therefore we define this under CacheBehaviors. Again, in all cases, we set the DefaultTTL to zero to ensure our cache-control headers control the TTL. The end result is that our multiple origins now look like one from the outside.

Note that ApiGatewayRestApi is the logical ...

Get JavaScript Cloud Native Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.