Getting Started
Install and configure @interlace serverless plugins in under 2 minutes.
Install
npm install --save-dev @interlace/serverless-api-gateway-caching @interlace/serverless-iam-roles-per-function @interlace/serverless-devkitpnpm add -D @interlace/serverless-api-gateway-caching @interlace/serverless-iam-roles-per-function @interlace/serverless-devkityarn add -D @interlace/serverless-api-gateway-caching @interlace/serverless-iam-roles-per-function @interlace/serverless-devkitbun add -d @interlace/serverless-api-gateway-caching @interlace/serverless-iam-roles-per-function @interlace/serverless-devkitQuick Start
Add the plugin to your serverless.yml:
plugins:
- '@interlace/serverless-api-gateway-caching'
custom:
interlaceCaching:
enabled: true
clusterSize: '0.5'
ttlInSeconds: 300
flushOnDeploy: true
functions:
getUser:
handler: src/handler.get
events:
- http:
path: /users/{id}
method: get
caching:
enabled: true
cacheKeyParameters:
- name: request.path.idOr use TypeScript
import { defineConfig, defineFunction } from '@interlace/serverless-devkit';
export default defineConfig({
service: 'my-api',
provider: {
name: 'aws',
runtime: 'nodejs20.x',
region: 'us-east-1',
},
plugins: ['@interlace/serverless-api-gateway-caching'],
custom: {
interlaceCaching: {
enabled: true,
clusterSize: '0.5',
ttlInSeconds: 300,
},
},
functions: {
getUser: defineFunction({
handler: 'src/handler.get',
events: [
{
http: {
path: '/users/{id}',
method: 'get',
caching: {
enabled: true,
cacheKeyParameters: [{ name: 'request.path.id' }],
},
},
},
],
}),
},
});Deploy
sls deploy --aws-profile interlaceVerify
sls caching status
# --- Cache Status ---
# Enabled: true
# Size: 0.5 GB
# Status: AVAILABLEWhat's next?
- Caching plugin configuration — full config reference
- Cache key parameters — path, query, header, and body keys
- Migration guide — switch from the community plugin
- Devkit API —
defineConfig(),defineFunction(), typed helpers