How it works...

This recipe builds on the Implementing a materialized view in S3 and Implementing a search BFF recipes. We define the bucket's NotificationConfiguration to send events to the SNS BucketTopic so that we can trigger more than one consumer. In the Implementing a search BFF recipe, we triggered indexing in Elasticsearch. In this recipe, we demonstrate how we can also trigger the invalidation of the cache in the CloudFront distribution. The trigger function creates an invalidation request for each trigger.s3.object.key. These invalidations will force the CDN to retrieve these resources from the origin the next time they are requested.

A slow flow of invalidations does not incur significant cost. However, large batches of individual ...

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.