cdk-bucket-deployment-expirator
TypeScript icon, indicating that this package has built-in type declarations

1.87.1 • Public • Published

CDK Bucket Deployment Expirator

build codecov dependencies Status npm

npm version PyPI version

Why This Package

I've been having issues with my React deployments to AWS S3 while using Cloudfront due to browsers caching and attempting to load chunks that were unavailable after using CDK Bucket Deployment.

I had been using prune: true to clean up the bucket and this was causing all previous chunks to be deleted. However, the reality is we want to support N number of older chunks, just in case, and provide a mechanism for alerting the user that a new version is available (not part of this construct).

Must Be Used With CDK Bucket Deployment

import { Bucket } from '@aws-cdk/aws-s3';
import { BucketDeployment, Source } from '@aws-cdk/aws-s3-deployment';

...
...

const bucket = new Bucket(this, 'SourceBucket');
const now = new Date().getTime();

const bucketDeployment = new BucketDeployment(this, 'deploy-spa', {
  sources: [Source.asset('path/to/assets')],
  destinationBucket: bucket,
  metadata: { deployed: now.toString() },
  prune: false
});

new BucketDeploymentExpirator(this, 'expirator', {
  bucketDeployment: bucketDeployment, // need this to add cfn depends on
  sourceBucket: bucket
})

Versioning

I will attempt to align the major and minor version of this package with [AWS CDK], but always check the release descriptions for compatibility.

This currently supports GitHub package.json dependency version (prod)

References

Readme

Keywords

Package Sidebar

Install

npm i cdk-bucket-deployment-expirator

Weekly Downloads

3

Version

1.87.1

License

Apache-2.0

Unpacked Size

12 MB

Total Files

11

Last publish

Collaborators

  • kwinner