33A [ layer] ( https://aws.amazon.com/about-aws/whats-new/2018/11/aws-lambda-now-supports-custom-runtimes-and-layers/ )
44for AWS Lambda that allows your functions to use ` openssl ` binaries.
55
6- ## Getting Started
6+ This repository contains the code needed to create an AWS Lambda Layer that
7+ adds the OpenSSL binary and related files to a Lambda container.
78
8- You can add this layer to any Lambda function you want.
9- ` PATH ` already includes ` /opt/bin ` in Lambda, which is where it will be mounted .
9+ This is useful because Lambda Runtimes based on Amazon Linux 2 and newer do not
10+ include this binary .
1011
11- Click on Layers and choose "Add a layer", and "Provide a layer version
12- ARN" and enter the following ARN (replace ` us-east-1 ` with the region of your Lambda):
12+ ## How to build
1313
14+ To build the zip, just run
1415```
15- arn:aws:lambda:us-east-1:034541671702:layer:openssl-lambda:1
16+ cd src
17+ ./build.sh
1618```
1719
20+ Then, log in to AWS Console, navigate to Lambda, and find the Layers subsection
21+ in the sidebar.
22+
23+ There you can create a new layer, fill in the required details, and upload the
24+ zip you just created. After finishing this process, the new layer is available
25+ to be used in you lambda functions!
26+
27+ ## Using a Lambda Layer
28+
29+ You can add this layer to any Lambda function you want.
30+ ` PATH ` already includes ` /opt/bin ` in Lambda, which is where it will be mounted.
31+
32+ In some Runtimes, you may still need to alter the ` LD_LIBRARY_PATH ` environment
33+ variable, prepending /opt/lib64 to override the .so files already present in
34+ the image.
35+
36+ In AWS Lambda console, find your function, then scroll down to Layers and
37+ choose "Add a layer", then select your layer.
38+
1839![ Provide layer ARN] ( https://raw.githubusercontent.com/alexandredavi/openssl-lambda-layer/master/img/provide.PNG " Provide layer ARN screenshot ")
1940
2041Then click Add, save your lambda and test it out!
2142
2243![ Referenced layers] ( https://raw.githubusercontent.com/alexandredavi/openssl-lambda-layer/master/img/referenced.PNG " Referenced layer ARN screenshot ")
2344
45+
2446## Simple example on Node.js
2547
2648``` js
@@ -30,3 +52,13 @@ exports.handler = async(event) => {
3052 execSync (' openssl genrsa -out testCert.key 2048' , { encoding: ' utf8' , stdio: ' inherit' })
3153}
3254```
55+
56+ ## Simple example on Python
57+
58+ ``` python
59+ import os
60+ import subprocess
61+
62+ def handler (event , context ):
63+ subprocess.run(" openssl genrsa 2048" , env = {' PATH' : os.environ[' PATH' ]})
64+ ```
0 commit comments