CloudFront invalidations are [very error prone](https://github.com/aws/aws-cdk/issues/15891#issuecomment-966456154), making it hard to invalidate distributions reliably. This construct aims to solve this problem by using a step function which is triggered on stack update, and uses exponential backoff to retry the invalidation. Inspired by https://github.com/aws/aws-cdk/issues/15891#issuecomment-1362163142.
Project description
@reapit-cdk/cloudfront-invalidation
CloudFront invalidations are very error prone, making it hard to invalidate distributions reliably. This construct aims to solve this problem by using a step function which is triggered on stack update, and uses exponential backoff to retry the invalidation. Inspired by https://github.com/aws/aws-cdk/issues/15891#issuecomment-1362163142.
Package Installation:
yarn add --dev @reapit-cdk/cloudfront-invalidation
# or
npm install @reapit-cdk/cloudfront-invalidation --save-dev
Usage
import { Stack, App } from 'aws-cdk-lib'
import { Distribution } from 'aws-cdk-lib/aws-cloudfront'
import { HttpOrigin } from 'aws-cdk-lib/aws-cloudfront-origins'
import { CloudfrontInvalidation } from '@reapit-cdk/cloudfront-invalidation'
const app = new App()
const stack = new Stack(app, 'stack-name', {
env: {
region: 'us-east-1', // region must be specified
},
})
const distribution = new Distribution(stack, 'distribution', {
defaultBehavior: {
origin: new HttpOrigin('example.org'),
},
})
new CloudfrontInvalidation(stack, 'invalidation', {
distribution,
items: ['/index.html', '/config.js'], // path patterns you want invalidated
})
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for reapit-cdk.cloudfront-invalidation-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4ffae121ff6337f55fda9d33f3edf09c325c5f7468936bd5380c44a08522315 |
|
MD5 | f8d4d5e2ca0eed57f667998d4b729549 |
|
BLAKE2b-256 | 155f0555119bf8cd291d82c2cd89c09a44b9388daa9d36ee123fdfc5f917790e |
Hashes for reapit_cdk.cloudfront_invalidation-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b5231a228da25e5d45ba33fb540e3a80e259d8485d89331f2439dd1bb1d5022 |
|
MD5 | cecf1dfbed3e6fe95d8edcd3863c837a |
|
BLAKE2b-256 | 6be3500b3f6e319ba740c7137e6d8bf35dc9ba4bcb9a9d5ad7ce2d1e6e69ee3a |