1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-12 03:00:28 +00:00
TiddlyWiki5/plugins/tiddlywiki/aws/docs/lambda.tid

58 lines
1.5 KiB
Plaintext
Raw Normal View History

title: $:/plugins/tiddlywiki/aws/lambda
! Template
The template [[$:/plugins/tiddlywiki/aws/lambdas/main]] transcludes everything required to render a TiddlyWiki as an AWS Lambda function.
The Lambda is build with this command:
```
tiddlywiki editions/aws --rendertiddler $:/plugins/tiddlywiki/aws/lambdas/main index.js text/plain
```
Or:
```
tiddlywiki editions/aws --build lambda
```
! Execution
The Lambda boot code looks for an array of tiddlers to load in `event.tiddlers`, and an array of commands to execute in `event.commands`. For example:
```
{
"commands": [
"--aws","s3-rendertiddler","HelloThere","eu-west-2","my-bucket-name","rendered.html"
],
"tiddlers": [
{
"title": "HelloThere",
"text": "Hello from {{Platform}}."
},
{
"title": "Platform",
"text": "TiddlyWiki"
}
]
}
```
The event data can optionally be compressed by passing a JSON object with a single property `compressed` that contains a base64 encoded GZIP compressed representation of the JSON payload data. For example:
```
var strPayload = JSON.stringify(payload);
require("zlib").gzip(strPayload,function(err,buff) {
var compressedPayload = {compressed: new Buffer(buff).toString("base64")};
// Invoke lambda with compressed payload
...
});
```
! Return data
If the Lambda function successfully executes it returns an object with the following fields:
* ''lambda-result'': An array of `{bucketname,key}` pairs for each file written to S3 within the lambda function