Skip to content

Repository files navigation

Cloudfront invalidation queue

CloudFormationStepFunctionsCloudfront

Collect Cloudfront invalidations in a custom queue and process them in batch.

Created resources

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.

Infrastructure Schema

Installation

RegionDeploy Link
eu-west-1Launch Stack in region eu-west-1
eu-central-1Launch Stack in region eu-central-1
us-east-1Launch Stack in region us-east-1
us-east-2Launch Stack in region 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-31Resources:
CloudfrontInvalidationQueue:
Type: AWS::CloudFormation::StackProperties:
TemplateURL: # pick a templates links from section below, based on your regionParameters:
DistributionId: XXXXXXXXXXXXXXX

Public templates

RegionTemplate URLs
eu-west-1https://bitbull-serverless-templates-butoamoogh8eigo.s3.eu-west-1.amazonaws.com/cloudfront-invalidation-queue/template.yml
eu-central-1https://bitbull-serverless-templates-saijuozaeshae6e.s3.eu-central-1.amazonaws.com/cloudfront-invalidation-queue/template.yml
us-east-1https://bitbull-serverless-templates-chai7ephae5eet2.s3.us-east-1.amazonaws.com/cloudfront-invalidation-queue/template.yml
us-east-2https://bitbull-serverless-templates-xae9och1eipiem8.s3.us-east-2.amazonaws.com/cloudfront-invalidation-queue/template.yml

Parameters

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.

Usage

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/"
]
}

Credits

About

Collect Cloudfront invalidations in a custom queue and process them in batch.

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Contributors

Languages