Skip to content

Commit 49d633e

Browse files
committed
lambda layer
1 parent 0ed7eab commit 49d633e

File tree

5 files changed

+45
-74
lines changed

5 files changed

+45
-74
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
build

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
DEPLOYMENT_BUCKET_NAME := claudia-layers
2+
DEPLOYMENT_KEY := $(shell echo pandoc-$$RANDOM.zip)
3+
STACK_NAME := pandoc-lambda-layer
4+
5+
clean:
6+
rm -rf build
7+
8+
build/bin/pandoc: vendor/pandoc.gz
9+
mkdir -p build/bin
10+
cp vendor/pandoc.gz build/bin
11+
gzip -d build/bin/pandoc.gz
12+
13+
build/layer.zip: build/bin/pandoc
14+
cd build && zip -r layer.zip bin
15+
16+
# cloudformation has no support for packaging layers yet, so need to do this manually
17+
#
18+
build/output.yml: build/layer.zip cloudformation/template.yml
19+
aws s3 cp build/layer.zip s3://$(DEPLOYMENT_BUCKET_NAME)/$(DEPLOYMENT_KEY)
20+
sed "s:DEPLOYMENT_BUCKET_NAME:$(DEPLOYMENT_BUCKET_NAME):;s:DEPLOYMENT_KEY:$(DEPLOYMENT_KEY):" cloudformation/template.yml > build/output.yml
21+
22+
deploy: build/output.yml
23+
aws cloudformation deploy --template-file build/output.yml --stack-name $(STACK_NAME)
24+
aws cloudformation describe-stacks --stack-name $(STACK_NAME) --query Stacks[].Outputs[].OutputValue --output text
25+

README.md

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,9 @@
11
# Pandoc for AWS Lambda
22

3-
This is a binary package and a Node.js wrapper for a precompiled version of [Pandoc](http://pandoc.org/) for the Amazon Linux machine image used by AWS Lambda. It can help you get started quickly with Pandoc inside Lambda functions.
3+
This is a precompiled version of [Pandoc](http://pandoc.org/) for the Amazon Linux machine image used by AWS Lambda, deployable as an AWS lambda layer. It can help you get started quickly with Pandoc inside Lambda functions.
44

55
Check out the [Running Pandoc on Lambda Guide](https://claudiajs.com/tutorials/pandoc-lambda.html) for information on how this binary was produced, and how to compile a different version yourself with modified options.
66

7-
## Usage without Node.js
8-
9-
To use without Node.js, grab the binary from [vendor/pandoc.gz](vendor/pandoc.gz) and upload to Lambda yourself. This is gzipped to save space, so unpack it first before executing.
10-
11-
## Usage from Node.js
12-
13-
Include the `pandoc-aws-lambda-binary` package using NPM, and make sure to package it with your Lambda function code:
14-
15-
```bash
16-
npm install pandoc-aws-lambda-binary -S
17-
```
18-
19-
Require and call the NPM package function from your Lambda code:
20-
21-
22-
```js
23-
var pandoc = require('pandoc-aws-lambda-binary');
24-
25-
var resultPromise = pandoc(inputFilePath, outputFilePath, additionalOptions);
26-
```
27-
28-
### Options
29-
30-
* `inputFilePath`: `string` -- file you want to convert
31-
* `outputFilePath`: `string` -- path to save the results
32-
* `additionalOptions`: `array` -- any other options you want to pass to the pandoc executable
33-
34-
The options will be concatenated into a command such as `pandoc inputFilePath -o outputFilePath additionalOptions`.
35-
36-
### Return value
37-
38-
The `pandoc` function is asynchronous and returns a JavaScript Promise, that will be resolved or rejected depending on the results of the command execution.
39-
40-
### Full Example
41-
42-
Check out the [Pandoc S3 Converter Example Project](https://github.com/claudiajs/example-projects/tree/master/pandoc-s3-converter) to see how to wire everything up into a Lambda function.
43-
44-
## Local usage
45-
46-
To run this in local tests, define a `PANDOC_PATH` environment variable and set it to your local Pandoc executable. It will then use the provided executable instead of unpacking the Lambda binary
47-
487
## Version information
498

509
Compiled for [`ami-4fffc83`](https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#Images:visibility=public-images;search=amzn-ami-hvm-2017.03.1.20170812-x86_64-gp2;sort=name), for Linux kernel version 4.9.38-16.35.amzn1.x86_64.

cloudformation/template.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Description: Pandoc AWS Lambda Layer
2+
3+
Resources:
4+
PandocLayer:
5+
Type: AWS::Lambda::LayerVersion
6+
Properties:
7+
CompatibleRuntimes:
8+
- nodejs8.10
9+
Description: Pandoc for AWS Lambda
10+
LayerName: pandoc
11+
LicenseInfo: GPL-2.0-or-later
12+
Content:
13+
S3Bucket: DEPLOYMENT_BUCKET_NAME
14+
S3Key: DEPLOYMENT_KEY
15+
16+
Outputs:
17+
PandocLayer:
18+
Value: !Ref PandocLayer

package.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)