Skip to content

Support custom target path inside ZIP file when packaging #3366

@gmetzker

Description

@gmetzker

For packaging it would be nice if we could specify the target location inside the ZIP location. I haven't figured out how to do this short of defining a custom packaging script.

This is a (Bug Report / Feature Proposal)

Description

For bug reports:

  • What went wrong?
  • What did you expect should have happened?
  • What was the config you used?
  • What stacktrace or error message from your provider did you see?

For feature proposals:

  • What is the use case that should be solved. The more detail you describe this in the easier it is to understand for us.

I'm using python (w/virtual environment) and deploying with serverless. Currently the serverless packaging features does not allow me to specify the target location in the zip file requires me to create a custom packaging script.

Here is my project structure.

./serverless.yml
./src/my_lambda.py
./src/core/other_file.py
/venv/lib/python2.7/site-packages/*

I need a package ZIP file with the following structure:

./my_lambda.py
./core/other_file.py
./{all pip packages from site-packages in root}

My use case is two fold:

  1. python virtual environment dependencies (for a local environment) are in a deep nested path but for lambda they are required at the package root in the ZIP. See lambda docs
  2. I would like to keep a cleaner project structure so I would like to keep the serverless.yml file out of the ./src directory.
  • If there is additional config how would it look

I would propose some additional syntax that allows you to specify the target location in the package ZIP file for each include statement.

I'm not sure what the best syntax might be but here is one idea.

package:
  exclude:
    - tests/**

  include:
    - source: src/**
      target: ./

    - source: $VIRTUAL_ENV/lib/python2.7/site-packages/**
      target: ./

  artifact: path/to/my-artifact.zip

For include statements. Define these as either string | object {source,target}
If include statement is an object source property defines the source glob statement as normal, but target specifies the desired destination location within the zip file. In the example I am targeting the root of the zip file.

Similar or dependent issues:

Additional Data

  • Serverless Framework Version you're using:
  • Operating System:
  • Stack Trace:
  • Provider Error messages:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions