serverless-plugin-cachette
v0.0.2
Published
Remote file retrieval/caching for AWS Lambda
Downloads
2
Readme
serverless-plugin-cachette
Serverless plugin for retreiving and caching files in lambda file system.
Features
Supported Runtimes:
- [x] http
- [ ] s3
Install
Serverless
serverless plugin install --name serverless-plugin-cachette
Manually
yarn add --dev serverless-plugin-cachette
# or
npm install -D serverless-plugin-cachette
Add the following plugin to your serverless.yml
:
plugins:
- serverless-plugin-cachette
Example Configuration:
custom:
cachette:
- type: http
fileName: test.json
url: "https://test.com/my-file.json"
method: post
headers:
api-key: mysecret
anotherHeader: content
For more information on Cachette and configuring look at its repo
Including/Excluding functions
If no include
or exclude
list is specified this will apply the cache to all layers by default.
If you would like to apply a cache to one or more functions: add the function name to an include
list.
If you would like to not apply a cache to one or more functions: add the function name to the exclude
list.
note: you cannot have both an include
and exclude
list on the same cache.
functions:
functionA:
handler: handler.handler
events:
- http:
method: get
path: a
functionB:
handler: handler.handler
events:
- http:
method: get
path: b
custom:
cachette:
- type: http
...
include:
- functionA
- type: http
...
exclude:
- functionA
- type: http
...
Target Types
Here are some of the methods you can use to pull and store data.
HTTP Target
Will make a HTTP request to a provided url
and store the response body as bytes to /tmp/<fileName>
type: http
fileName: <fileName>
url: <url>
method: <post|get|...>
headers: # This is optional
<header-key>: <header-value>