Skip to main content

Opinionated CDK Bucket Deployment object pruner for maintaining N old versions

Project description

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

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
from aws_cdk.aws_s3 import Bucket
from aws_cdk.aws_s3_deployment import BucketDeployment, Source

bucket = Bucket(self, "SourceBucket")
now = Date().get_time()

bucket_deployment = BucketDeployment(self, "deploy-spa",
    sources=[Source.asset("path/to/assets")],
    destination_bucket=bucket,
    metadata=UserDefinedObjectMetadata(deployed=now.to_string()),
    prune=False
)

BucketDeploymentExpirator(self, "expirator",
    bucket_deployment=bucket_deployment, # need this to add cfn depends on
    source_bucket=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

Project details


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

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page