Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/farrajota/docker-aws-lambda-builder
Use docker to build / package code with custom libraries for aws lambda
https://github.com/farrajota/docker-aws-lambda-builder
aws aws-lambda build docker package pipenv python
Last synced: about 12 hours ago
JSON representation
Use docker to build / package code with custom libraries for aws lambda
- Host: GitHub
- URL: https://github.com/farrajota/docker-aws-lambda-builder
- Owner: farrajota
- License: mit
- Created: 2019-01-23T21:42:23.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-25T14:36:18.000Z (almost 6 years ago)
- Last Synced: 2023-10-20T12:34:43.709Z (about 1 year ago)
- Topics: aws, aws-lambda, build, docker, package, pipenv, python
- Language: Shell
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Build and package code with custom libraries to aws lambda
Build and package code using custom libraries into an aws lambda compatible zip file with little to no effort. Additionally, you can also upload the packaged code to S3 using a simple command.
## Requirements
- [Docker](https://www.docker.com/)
- [aws cli](https://pypi.org/project/awscli/) (optional)
- Dependencies listed in either `requirements.txt` or `Pipfile.lock` / `Pipfile`## How to use
To build and package your code, all you need to do is to copy your code to the `code/` folder and run the following command:
```bash
$ make build-package
```This will build and package your code targetting Python 3.7 as the run time into a `zip` file (`lambda.zip`).
If you wish to target another version for python, or to change the output name of the zip file, you can use the `version=` and `filename=` input arguments, respectively:
```bash
$ make build-package version= filename=
```### Example
You want to build your code with Python 3.7 as a target, but you only have version 3.6 installed or you have been using Python 3.6 but want to package it using 3.7 with compatible libraries. Assuming you are using either a `requirements.txt` or a `Pipfile.lock` file to store the dependencies used in your code, to build and package your code painlessly, you need to do the following:
```bash
$ make build-package version=3.7 filename=example.zip
```This will generate the aws lambda compatible zip file `example.zip` containing all the specified libraries in `requirements.txt` or `Pipfile.lock` built targeting Python 3.7 as the runtime. If you wish to use another version of Python, all you need to do is change the target version from 3.7 to the version you want in the `make build-package` macro.
# Uploading to S3
In order to upload the file to S3, it is required you to have a authentication configured for aws-cli using either a config file (`~/.aws/credentials`) or environment variables. If you are using environment variables, you can set an account in the command line with the following commands:
```bash
$ export AWS_ACCESS_KEY_ID=
$ export AWS_SECRET_ACCESS_KEY=
```Then, to upload the packaged file to S3, run the following command in the terminal:
```bash
$ make upload filename= bucket=
```# License
[MIT](LICENSE)