@ryan-o-lee/serverless-offline-edge-lambda
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

serverless-offline-edge-lambda

NOTE: Package bumped with latest changes from master given v1.0.2 seems to be broken. This release is not supported and it is recommended to use https://github.com/evolv-ai/serverless-offline-edge-lambda once a new update has properly been released

A plugin for the Serverless Framework that simulates the behavior of AWS CloudFront Edge Lambdas while developing offline.

Setup

npm install --save-dev serverless
npm install --save-dev @ryanolee/serverless-offline-edge-lambda

serverless.yml

service:
  name: edge-lambdas
  
plugins:
  - '@ryanolee/serverless-offline-edge-lambda'

provider:
  name: aws
  runtime: nodejs8.10

functions:
  lambda:
    handler: src/handlers.onViewerRequest
    lambdaAtEdge:
      distribution: 'WebsiteDistribution'
      eventType: 'viewer-request'
      pathPattern: '/lambda'

resources:
  Resources:
    WebsiteDistribution:
      Type: 'AWS::CloudFront::Distribution'
      Properties:
        DistributionConfig:
          DefaultCacheBehavior:
npx serverless offline start --port=<port>

Use with serverless-offline

The plugin should not be used in conjunction with serverless-offline because both plugins define the offline command.

Use with serverless-plugin-cloudfront-lambda-edge

This plugin does not handle packaging and deploying edge lambdas to the cloud. Therefore this plugin can be used with serverless-plugin-cloudfront-lambda-edge. Again, doing so is optional. The schema in serverless.yml derives from that used by serverless-plugin-cloudfront-lambda-edge.

Use with Transpilers

This plugin can also be used with transpilers such as serverless-plugin-typescript. In the cases where the transpiler outputs built files to a path that differs from the path specified for the handlers (e.g. .build/src/handers.onViewerRequest), this plugin accepts a configuration option path that it uses to resolve function handlers.

plugins:
  - serverless-plugin-typescript
    
custom:
  offlineEdgeLambda:
    path: '.build'

Package Sidebar

Install

npm i @ryan-o-lee/serverless-offline-edge-lambda

Weekly Downloads

0

Version

1.0.3

License

Apache-2.0

Unpacked Size

87.3 kB

Total Files

93

Last publish

Collaborators

  • ryanolee