AWS Lambda Layers now make it possible to package a collection of dependencies together and can be shared across multiple Lambda Functions. AWS Lambda Layers can include language specific libraries, which the function will import to use.
This can break unit-tests written for Lambda Functions, as there may be imports that are provided via a Lambda Layer instead of via a build manifest (e.g. requirements.txt).
Therefore, we need a way to execute unit-tests within the same environment as when you run sam local invoke.
This problem also exists for other CI related checks like linting.
When you run unit-tests, linters etc, these may depend on additional build dependencies that you only need when running the checks but don't want in the final deploy, for example py.test. This would require some way of providing additional dependencies to the docker container that is used when running the checks.
It seems like some packagers provide a native way of specifying "dev" dependencies, for example pipenv and npm.
Perhaps we could add a new command sam dev build which would install the dev dependencies, and sam dev run to run commands under this environment which would also include layers.
Most helpful comment
It seems like some packagers provide a native way of specifying "dev" dependencies, for example pipenv and npm.
Perhaps we could add a new command
sam dev buildwhich would install the dev dependencies, andsam dev runto run commands under this environment which would also include layers.