s3-invalidate-cloudfront
v1.0.0
Published
Invalidate CloudFront caches for a bucket.
Readme
S3 invalidate CloudFront
Invalidate CloudFront caches for a bucket.
Motivation
After uploading to an S3 bucket I need to invalidate the CloudFront cache:
> aws s3 sync src/ s3://bucket-name
> aws cloudfront create-invalidation --distribution-id cloudfront-distribution-id --paths "/*"The AWS cli only accepts distribution IDs which then have to be hardcoded. It would be much more ergonomic if I could lookup the matching distribution IDs based on the bucket name:
> s3-invalidate-cloudfront bucket-name
Deleted cloudfront-distribution-id at path /*Benefits:
- Uses the bucket name which is recognisable and not allocated by AWS like the distribution ID
- Simplifies invalidating caches for a bucket that has multiple cloudfront consumers
I also want to programmatically invalidate caches:
import { lookup, invalidate } from "s3-invalidate-cloudfront";
lookup("bucket-name", "us-east-1").then((caches) => Promise.all(caches.map(invalidate)));Installing
npm install s3-invalidate-cloudfrontTo make the cli accessible install the package globally with the -g flag or invoke it with npx.
Usage
s3-invalidate-cloudfront bucket-nameCLI
s3-invalidate-cloudfront <name>
Invalidate CloudFront caches for a bucket.
Positionals:
name The bucket name [string]
Options:
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-r, --region Set the AWS region [string] [default: "us-east-1"]
-d, --dry-run Don't make any changes [boolean] [default: false]Tooling
Dependencies
To install dependencies:
yarn installTests
To run tests:
yarn testDocumentation
To generate the documentation locally:
yarn docsLinters
To run linters:
yarn lintFormatters
To run formatters:
yarn formatContributing
Please read this repository's Code of Conduct which outlines our collaboration standards and the Changelog for details on breaking changes that have been made.
This repository adheres to semantic versioning standards. For more information on semantic versioning visit SemVer.
Bump2version is used to version and tag changes. For example:
bump2version patchContributors
- Joel Lefkowitz - Initial work
Remarks
Lots of love to the open source community!
