Serverless Framework plugin that automatically invalidates CloudFront cache after deployment. Version 1.12.2 is the latest stable release, with updates as needed (not on a fixed cadence). Unlike manual AWS CLI commands or custom scripts, this plugin integrates directly into the Serverless deployment lifecycle, ensuring cache invalidation happens automatically after each `sls deploy`. It supports multiple distributions, stage-specific invalidation, and standalone invalidation via `sls cloudfrontInvalidate`. It is actively maintained with support for self-signed certificates and proxy configurations.
npm install serverless-cloudfront-invalidateNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Minimal configuration to auto-invalidate CloudFront after each deploy.
Always place `serverless-cloudfront-invalidate` at the end of the plugins list.
Ensure the CloudFormation Output is defined and outputs the Ref of the CDN resource. The plugin reads the output after stack creation.
Set `autoInvalidate: false` on the invalidation config for non-production stages or use stage-specific configurations.
Always provide at least one path in the `items` array (e.g., \"/*\" or \"/index.html\").
Define the CloudFormation Output in the resources section with the same key, or use a literal `distributionId` instead.
Run `npm install --save-dev serverless-cloudfront-invalidate` and ensure the plugin name is exactly `serverless-cloudfront-invalidate`.
Ensure all paths start with `/` and are URL-encoded if containing special characters. For large batches, use wildcards like `/static/*` or `/images/*` to reduce path count.