Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f9dce32

Browse files
committed
pushing layer dependency into .vendor for added clarity
1 parent 620da53 commit f9dce32

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

‎README.md‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
11
## "Using AWS Lambda layers to inject lantency into AWS Lambda functions"
22

3+
## Building the zip package on a MAC (easy on Linux)
4+
1. If you upload the Mac version of ZIP files with PIP requirements installed with a MAC environment, you’ll see "invalid ELF header" logs when you try to test your Lambda function.
5+
* You need Linux versions of library files to be able to run in AWS Lambda environment. That's where Docker comes in handy.
6+
* With Docker you can very easily can run a Linux container locally on your Mac, install the Python libraries within the container so they are automatically in the right Linux format, and zip up the files ready to upload to AWS.
7+
* You’ll need Docker for Mac installed first. (https://www.docker.com/products/docker)
38

9+
2. Spin up an Ubuntu container which will have the lambda code you want to package
10+
* run the following command:
11+
12+
```
13+
$ docker run -v <full path directory with your code>:/working -it --rm ubuntu
14+
```
15+
The -v flag makes your code directory available inside the container in a directory called "working".
16+
You should now be inside the container at a shell prompt.
17+
18+
3. Install pip and zip.
19+
* run the following commands:
20+
```
21+
$ apt-get update
22+
$ apt-get install python-pip
23+
$ apt-get install zip
24+
```
25+
26+
4. Install the python requirements.
27+
* run the following commands:
28+
```
29+
$ cd working
30+
$ pip install -r python/requirements.txt -t ./python/.vendor
31+
```
32+
33+
5. Package your code.
34+
* run the following commands:
35+
```
36+
$ zip -r chaos_lib.zip ./python
37+
```
38+
39+
Voila! Your package file chaos_lib.zip is ready to be used in Lambda Layer.

‎lambda_function.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from local_settings import environment
12
from chaos_lib import delayit
23
from chaos_lib import SessionWithDelay
34

‎python/chaos_lib.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
from __future__ import division, unicode_literals
2+
3+
import sys
4+
sys.path.insert(0, '/opt/python/.vendor')
5+
26
from ssm_cache import SSMParameter
37
import time
48
import random

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /