Collect Cloudfront invalidations in a custom queue and process them in batch.
Creates a Lambda function, triggered by EventBridge's event, that store the queue into a DynamoDB table and use a StepFunction state machine to orchestrate the execution of second Lambda that create the Cloudfront invalidation.
Region | Deploy Link |
---|---|
eu-west-1 | ![]() |
eu-central-1 | ![]() |
us-east-1 | ![]() |
us-east-2 | ![]() |
Using the SAM CLI:
sam build
sam deploy --guided
Including in an other SAM template:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
CloudfrontInvalidationQueue:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: # pick a templates links from section below, based on your region
Parameters:
DistributionId: XXXXXXXXXXXXXXX
This application require some parameters when you deploy it:
- DistributionId:The Cloudfront distribution id to invalidate.
Optional parameters:
-
EventBusName: The event bus from which to listen to the invalidation event.
-
BatchWindowSeconds: The batch window in seconds.
-
BatchTTL: The TTL value for batch, in seconds.
Send an event to configured EventBus with DetailType as Cloudfront Invalidation Request
and Detail as
{
"Paths": [
"/path/to/invalidate",
"/path/to/invalidate/",
"/an/other/path/to/invalidate",
"/an/other/path/to/invalidate/"
]
}
- Repository badges by Shields.io
- Infrastructure schema by Cloudcraft