31 lines
1.1 KiB
Markdown
31 lines
1.1 KiB
Markdown
# PDF Label Cropper
|
|
|
|
## Deployment
|
|
|
|
[Documentation](https://docs.aws.amazon.com/lambda/latest/dg/python-package.html)
|
|
|
|
This creates a zip file structured for AWS Lambda deployment. The virtual environment steps are only required if the
|
|
packages are updated.
|
|
|
|
- `python -m venv lambda_env`
|
|
- `source ./lambda_env/bin/activate`
|
|
- `pip install pypdf pdfplumber`
|
|
|
|
Note the location of installed packages with `pip show pypdf` and modify the following commands if necessary.
|
|
|
|
- `deactivate`
|
|
- `cd lambda_env/lib/python3.13/site-packages/`
|
|
- `zip -r ../../../../_deploy/pdf-crop.zip .`
|
|
- `cd ../../../../`
|
|
|
|
At this point, the zip file only contains the packages. To add the custom code and the lambda function, run the
|
|
following command from the project root. This is the same command used to update the custom code.
|
|
|
|
- `zip _deploy/pdf-crop.zip cropper.py lambda_function.py`
|
|
|
|
Inspect zip contents with `unzip -l _deploy/pdf-crop.zip`
|
|
|
|
Update the lambda function with (make sure specify the credentials and region):
|
|
|
|
`aws lambda update-function-code --function-name pdf-label-crop --zip-file fileb://_deploy/pdf-crop.zip`
|