0 purchases
reapitcdk.cloudfrontinvalidation 0.1.2
@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
})
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.