Package
Zappa provides a command to generate a build package archive locally without deploying the application:
$ zappa package production
When you run this command, Zappa automatically packages your active virtual environment into an AWS Lambda compatible package.
Internally, it replaces any local dependencies with AWS Lambda compatible, precompiled versions. These dependencies are included in the following order:
- Lambda compatible many Linux wheels from the local cache
- Lambda compatible many Linux wheels from PyPi
- Lambda-specific versions from Lambda packages (https://github.com/Miserlou/lambda-packages)
- Archive the active virtual environment
- Archive the project directory
While processing, packaging, and packing, Zappa ignores some unnecessary files such as .pyc files. If they are available, then .py will get ignored. Zappa also sets the correct execution permissions, configures package settings, and creates a unique, auditable package manifest file.
The generated package archive will be Lambda compatible. You can set a callback function that will be invoked once the archive is created:
{
"production": {
"callbacks": {
"zip": "my_app.zip_callback"
}
}
}
Here, production is your stage name and under callback, you can set the callback method by mapping to "zip". This can help you write your own custom deployment automation.
We have seen the basic uses of Zappa. Now it's time to do some practical work. We are going to build some Python application developments with Zappa, so stay tuned!