npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sls-cloudfront-invalidate

v1.12.3

Published

Serverless plugin that allows you to invalidate Cloudfront Cache

Downloads

3

Readme

sls-cloudfront-invalidate

Serverless plugin that allows you to invalidate Cloudfront Cache. It was originally created by @aghadiry. You can find the original repository [https://github.com/aghadiry/serverless-cloudfront-invalidate]

I am maintaining this fork of the library, primarily focusing on updating the dependencies.

Installation

To install this library, you can use npm:

npm install [package-name]


## Install

Run `npm install` in your Serverless project.

```sh
$ npm install --save serverless-cloudfront-invalidate

Setup

Add the plugin to your serverless.yml file as the last plugin

plugins:
  - serverless-cloudfront-invalidate # add as the last plugin

If the CDN is created as part of same serverless.yml then you can specify the distributionIdKey and output the DomainId (as shown in the sample below).

custom:
  cloudfrontInvalidate:
    - distributionId: "CLOUDFRONT_DIST_ID" #conditional, distributionId or distributionIdKey is required.
      distributionIdKey: "CDNDistributionId" #conditional, distributionId or distributionIdKey is required.
      autoInvalidate: true # Can be set to false to avoid automatic invalidation after the deployment. Useful if you want to manually trigger the invalidation later. Defaults to true.
      items: # one or more paths required
        - "/index.html"
      stage: "dev"  # conditional, the stage that this cloudfront invalidation should be created
            # this should match the provider's stage you declared, e.g. "dev" but not "prod" in this case
            # an invalidation for this distribution will be created when executing `sls deploy --stage dev`
    - distributionId: "CLOUDFRONT_DIST_ID" #conditional, distributionId or distributionIdKey is required.
      distributionIdKey: "CDNDistributionId" #conditional, distributionId or distributionIdKey is required.
      items: # one or more paths required
        - "/index.html"
      # `stage` is omitted, an invalidation will be created for this distribution at all stages
resources:
  Resources:
    CDN:
      Type: "AWS::CloudFront::Distribution"
      Properties: ....
  Outputs:
    CDNDistributionId:
      Description: CDN distribution id.
      Value:
        Ref: CDN

Usage

Run sls deploy. After the deployment a Cloudfront Invalidation will be started. Run sls cloudfrontInvalidate to do a standalone invalidation

Options

The following options are supported:

cacert

Used to specify a cacert file for the AWS commands. This is useful for self signed certificates. You will need to specify the self signed cert in 2 places, one for the serverless execution and one for the AWS execution.

  • Use export cafile=<path to cert file> to use self signed cert for serverless execution
  • Run sls cloudfrontInvalidate --cacert=<path to ca cert file> to use self signed cert for AWS execution
Proxy

You can communicate with AWS even if you are using a proxy by setting the proxy to the environment variable of the execution environment.

  • Correspond to the following environment variable names

    • proxy
    • HTTP_PROXY
    • http_proxy
    • HTTPS_PROXY
    • https_proxy
  • example

    windows: set HTTP_PROXY=http://localhost:8080

    mac: export HTTP_PROXY=http://localhost:8080