GithubHelp home page GithubHelp logo

epsagon / serverless-package-external Goto Github PK

View Code? Open in Web Editor NEW
55.0 4.0 5.0 174 KB

Add external folders to the deploy package ๐Ÿ“ฆ

Home Page: https://epsagon.com/blog/how-to-package-external-code-in-aws-lambda-using-serverless-framework/

License: MIT License

JavaScript 100.00%
serverless serverless-framework aws-lambda serverless-plugin serverless-package serverless-external serverless-common

serverless-package-external's Introduction

serverless-package-external ๐Ÿ“ฆ

serverless semantic-release npm version Build Status

Deploy a Serverless Python Function services with external code

Before deploying, this plugin symlinks folders containing shared code into the root directory of your Serverless function. This plugin works also with serverless-offline plugin.

Installation

npm i serverless-package-external --save-dev

Usage

service: service-name

plugins:
  - serverless-package-external

functions:
  # Your functions here

custom:
  packageExternal:
    external:
      - '../common'
      - '../service-a/module'

Example Directory Structure

โ””โ”€โ”€ common
    โ””โ”€โ”€ resource.py
โ””โ”€โ”€ service-a
    โ””โ”€โ”€ handler.py
    โ””โ”€โ”€ serverless.yml
    โ””โ”€โ”€ module
        โ””โ”€โ”€ main.py
โ””โ”€โ”€ service-b
    โ””โ”€โ”€ handler.py
    โ””โ”€โ”€ serverless.yml

In handler.py, external code can be imported:

from common.resource import shared_resource

Licensing

serverless-package-external is licensed under the MIT License.

It is originally based on serverless-package-common.

serverless-package-external's People

Contributors

borjamacedo avatar ciekawy avatar dependabot[bot] avatar ranrib avatar shimonuri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

serverless-package-external's Issues

Not working in serverless-offline

from jwt.basic import get_cors_configured_response ModuleNotFoundError: No module named 'jwt.basic'
But the Lambda works when it is deployed.
I'm using python virutal environment while working in offline

EPERM: operation not permitted, scandir

just installed the plugin and currently using it in with windows. and I have encountered this issue with the library.

`Serverless: [serverless-package-external] Symlinking ../shared_code
Serverless: [serverless-package-external] is complete
Serverless: Packaging service...

Error --------------------------------------------------

EPERM: operation not permitted, scandir 'C:\mydir\shared_code'`

serverless-package-external deleted my project folder

Running serverless package with this plugin. it deletes my project folders with unpushed source codes...

This is the only error I got. I don't have any source code to show what config I set LOL.

Serverless: [serverless-package-external] Symlinking utils/**
Serverless: [serverless-package-external] Symlinking keys/**
Serverless: [serverless-package-external] Symlinking gql/**

  Error --------------------------------------------------

  Error: ENOENT: no such file or directory, symlink 'utils/**' -> '/Users/x/xx/xxx-lambda/**'
      at Object.symlinkSync (fs.js:1005:3)
      at /Users/x/xx/xx-lambda/node_modules/serverless-package-external/src/symlink.js:45:10
      at async Promise.all (index 0)

How does Serverless-Offline integration work?

The readme indicates the package works with serverless-offline, but I see no indication of any symlinks being created when invoking serverless-offline, nor does importing a local package from elsewhere work (a error about missing module is given). Is there a manual step I'm missing?

The package works fine when actually packaging to deploy, just not for offline testing.

Support for nodejs

In your description it seems like this only works with python, is that correct ?
if this is the case, how about supporting nodejs ?

No symlink when deploying locally

Hi,

Is it possible to symlink the folders when running locally (sls deploy local -f xxxxx)?
Sometimes it's useful to do some tests by deploying directly but with serverless-package-external active I'm unable to deploy local changes.

Thanks

does not work with sls offline (without start)

some plugins like serverless-s3-local , serverless-dynamodb-local follow different lifecycle and they do stop for offline:start:end - the only way to use them is to do sls offline without start param. Also start triggers daemon mode while no start runs offline in pending mode waiting for Ctrl-C which is useful in some cases

to make this great plugin working also without start param there should be added

"before:offline:start": this.beforeDeploy.bind(this)

local testing

Hello,

Is there anyway to test locally with this? Such as running test cases the paths don't resolve since it's only done when packaged.

Thank you

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.