GithubHelp home page GithubHelp logo

isabella232 / serverless-lambda-edge-pre-existing-cloudfront Goto Github PK

View Code? Open in Web Editor NEW

This project forked from serverless-operations/serverless-lambda-edge-pre-existing-cloudfront

0.0 0.0 0.0 370 KB

A Serverless Framework plugin to create your Lambda@Edge against a pre-existing CloudFront.

License: Other

JavaScript 100.00%

serverless-lambda-edge-pre-existing-cloudfront's Introduction

Serverless Lambda Edge PreExisting CloudFront

A Serverless Framework plugin which associates Lambda@Edge against pre-existing CloudFront distributions.

Install

You can install this plugin from npm registry.

$ npm install --save-dev serverless-lambda-edge-pre-existing-cloudfront

How it works

Configure serverless.yml

functions:
  viewerRequest:
    handler: lambdaEdge/viewerRequest.handler
    events:
      - preExistingCloudFront:
        # ---- Mandatory Properties -----
          distributionId: xxxxxxx # CloudFront distribution ID you want to associate
          eventType: viewer-request # Choose event to trigger your Lambda function, which are `viewer-request`, `origin-request`, `origin-response` or `viewer-response`
          pathPattern: '*' # Specifying the CloudFront behavior
          includeBody: false # Whether including body or not within request
        # ---- Optional Property -----
          stage: dev # Specify the stage at which you want this CloudFront distribution to be updated

plugins:
  - serverless-lambda-edge-pre-existing-cloudfront

Run deploy

$ serverless deploy

You can specify additional configurations a lambdaEdgePreExistingCloudFront value in the custom section of your serverless.yml file. A validStages value allows you to specify valid stage names for deploy Lambda@Edge.

lambdaEdgePreExistingCloudFront:
  validStages:
    - staging
    - production

How validStages and stage properties work

This plugin will first check for validStages property defined in the custom section. If validStages is used, then all the preExistingCloudFront events are only possible to be updated at the validStages. If not used, all the preExistingCloudFront events are possible to be updated at any stage.

Then at all valid stages, the plugin checks - for each preExistingCloudFront event - if the provider's stage is the same as the stage property defined for each preExistingCloudFront event. If they match, then that particular preExistingCloudFront event will be updated.

If stage is not used for a preExistingCloudFront event, then that event will be updated at all validStages or all stages if validStages is not used.

serverless-lambda-edge-pre-existing-cloudfront's People

Contributors

horike37 avatar dependabot[bot] avatar mordka avatar andreafalzetti avatar hoonoh avatar medikoo avatar ijin avatar rphelan 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.