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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83483e4da270a65041d19afda458a35b0532baed0a10ecf4b64d320702e77e9a |
|
MD5 | cca744510e8ababd6ce9233d478942b2 |
|
BLAKE2b-256 | 82d4f5a3bb0d515854e6a820c4294253b7ae45b0454562a4c5aba1edcd138bd6 |
Hashes for reapit_cdk.cloudfront_invalidation-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a1a1a704879145f49c63597889d2436885007762bcf397cec1149b217f1c56f |
|
MD5 | 348b974025385ccb93797c20930635c4 |
|
BLAKE2b-256 | d2b196e07ee0ef09918b222d55bca6ec836b6e8a2200135f19ee321437a5f6fa |