|
1 | 1 | # LibreOffice for AWS Lambda as a layer |
2 | 2 |
|
3 | | -> 95 MB LibreOffice to fit inside AWS Lambda Layer compressed with Brotli |
| 3 | +> 95 MB LibreOffice to fit inside AWS Lambda Layer compressed with Brotli or gzip |
4 | 4 |
|
5 | 5 | Based on the [serverless-libreoffice](https://github.com/vladgolubev/serverless-libreoffice) project. |
6 | 6 |
|
7 | 7 | ## Getting Started |
8 | 8 |
|
9 | | -You can add this layer to any Lambda function you want – no matter what runtime |
10 | | - |
11 | | -Click on Layers and choose "Add a layer", and "Provide a layer version |
12 | | -ARN" and enter the following ARN. |
| 9 | +Click on Layers and choose "Add a layer", and "Provide a layer version ARN" and enter the following ARN. |
13 | 10 |
|
14 | 11 | ``` |
15 | 12 | arn:aws:lambda:us-east-1:764866452798:layer:libreoffice:9 |
16 | 13 | ``` |
17 | 14 |
|
18 | | -See the table below for other supported regions. |
| 15 | +See the table below for the list of supported regions and runtimes. |
19 | 16 |
|
20 | 17 | Works well with [aws-lambda-libreoffice npm package](https://github.com/shelfio/aws-lambda-libreoffice) |
21 | 18 |
|
22 | | -## What does this layer contain? |
| 19 | +## What's inside this layer? |
| 20 | + |
| 21 | +`libreoffice-brotli` layer contains `lo.tar.br` file which is LibreOffice v6.4.0.1 (https://github.com/vladgolubev/serverless-libreoffice/releases/tag/v6.4.0.1). Node.js has native Brotli unpacking support since version 10 so it's easy to unpack this file natively. Alternatively, you can use [aws-lambda-libreoffice npm package](https://github.com/shelfio/aws-lambda-libreoffice) to simplify this task. |
23 | 22 |
|
24 | | -This layer contains `lo.tar.br` file which is LibreOfficee v6.4.0.1 (https://github.com/vladgolubev/serverless-libreoffice/releases/tag/v6.4.0.1). |
| 23 | +`libreoffice-gzip` layer contains `lo.tar.gz` file which is LibreOffice v6.4.0.1 (https://github.com/vladgolubev/serverless-libreoffice/releases/tag/v6.4.0.1). |
25 | 24 |
|
26 | | -## Where is LibreOffice inside of Lambda? |
| 25 | +## How do I use this layer to launch LibreOffice? |
27 | 26 |
|
28 | | -It is at `/opt/lo.tar.br`. |
| 27 | +If you don't use [aws-lambda-libreoffice npm package](https://github.com/shelfio/aws-lambda-libreoffice), then these steps are roughly what you need to do. |
| 28 | + |
| 29 | +1. This layer just adds `/opt/lo.tar.br` or `/opt/lo.tar.gz` file to your Lambda runtime |
| 30 | +2. Unpack `/opt/lo.tar.br` or `/opt/lo.tar.gz` file during Lambda execution into `/tmp` folder which has 512 MB of free space. Make sure to do this OUTSIDE function handler code. |
| 31 | +This is an expensive task, so better to make it once on a warm start. |
| 32 | +3. LibreOffice binary will be located available at `/opt/instdir/program/soffice.bin` |
| 33 | +4. Check out `/test/index.js` for CLI arguments needed to run LibreOffice to convert a `.txt` file to `.pdf` for more details |
29 | 34 |
|
30 | 35 | ## Version ARNs |
31 | 36 |
|
@@ -79,3 +84,4 @@ Works with the following [AWS Lambda runtimes](https://docs.aws.amazon.com/lambd |
79 | 84 | ## License |
80 | 85 |
|
81 | 86 | MIT © [Shelf](https://shelf.io) |
| 87 | + |
0 commit comments