GithubHelp home page GithubHelp logo

janhartje / serverless-cloudfront-invalidation Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 692 KB

Serverless Plugin to invalidate CloudFront Instances

Home Page: https://www.npmjs.com/package/serverless-cloudfront-invalidation

License: MIT License

JavaScript 100.00%

serverless-cloudfront-invalidation's Introduction

serverless-cloudfront-invalidation

Serverless plugin that allows you to invalidate Cloudfront Cache

Install

Run npm install in your Serverless project.

$ npm install --save serverless-cloudfront-invalidation

Setup

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

plugins:
  - serverless-cloudfront-invalidation # 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:
  cloudfrontInvalidation:
    - 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 cloudfrontInvalidation 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 cloudfrontInvalidation --cacert=<path to ca cert file> to use self signed cert for AWS execution

serverless-cloudfront-invalidation's People

Contributors

janhartje avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.