Amazon API Gateway to Amazon DynamoDB including cache invalidation

API Gateway → Amazon DynamoDB → DynamoDB Streams → Amazon EventBridge

Create a functionless cache invalidation process

This sample project demonstrates how to use a functionless cache invalidation process when utilizing API Gateway and DynamoDB as a simple CRUD.
By introducing EventBridge to this architecture and enabling DynamoDB Streams, the MODIFY event fired into the stream can be captured, processed, and published to a custom EventBridge Event Bus using EventBridge Pipes.
Once the event is available on the custom EventBridge Event Bus, a rule can consume the event and target the API Gateway with a `Cache-Control: max-age=0` header and correct AWS IAM permissions `execute-api:InvalidateCache` using the ARN method for the target.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/apigw-cache-invalidation-eventbridge

Deploy

sam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

sam delete

Created by:

Mark White

Mark White

Principal Engineer at Dunelm

Follow on LinkedIn