serverless-plugin-warmup 7.1.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +1 -0
- package/README.md +7 -5
- package/package.json +3 -3
- package/src/config.js +3 -0
- package/src/schema.js +2 -4
- package/src/warmer.js +2 -1
package/.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text=auto eol=lf
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Keep your lambdas warm during winter.
|
|
|
10
10
|
|
|
11
11
|
**Requirements:**
|
|
12
12
|
* Node *v14.x* or higher
|
|
13
|
-
* Serverless *v3.
|
|
13
|
+
* Serverless *v3.8* or higher
|
|
14
14
|
* AWS provider
|
|
15
15
|
|
|
16
16
|
## How it works
|
|
@@ -45,7 +45,7 @@ custom:
|
|
|
45
45
|
- schedule: cron(0/5 8-17 ? * MON-FRI *)
|
|
46
46
|
concurrency: 10
|
|
47
47
|
verbose: true
|
|
48
|
-
logRetentionInDays:
|
|
48
|
+
logRetentionInDays: 14
|
|
49
49
|
outOfOfficeHoursWarmer:
|
|
50
50
|
enabled: true
|
|
51
51
|
events:
|
|
@@ -68,12 +68,13 @@ The options are the same for all the warmers:
|
|
|
68
68
|
* **vpc** The VPC and subnets in which to deploy. Can be any [Serverless VPC configuration](https://serverless.com/framework/docs/providers/aws/guide/functions#vpc-configuration) or be set to `false` in order to deploy the warmup function outside of a VPC (defaults to the vpc in the provider)
|
|
69
69
|
* **memorySize** The memory to be assigned to the warmer lambda (defaults to `128`)
|
|
70
70
|
* **events** The event that triggers the warmer lambda. Can be any [Serverless event](https://serverless.com/framework/docs/providers/aws/events/) (defaults to `- schedule: rate(5 minutes)`)
|
|
71
|
+
* **architecture** The [instruction set to use for the lambda](https://www.serverless.com/framework/docs/providers/aws/guide/functions#instruction-set-architecture) (defaults to `x86_64`)
|
|
71
72
|
* **package** The package configuration. Can be any [Serverless package configuration](https://serverless.com/framework/docs/providers/aws/guide/packaging#package-configuration) (defaults to `{ individually: true, patterns: ['!**', '.warmup/${warmerName}/**'] }`)
|
|
72
73
|
* **timeout** How many seconds until the warmer lambda times out. (defaults to `10`)
|
|
73
74
|
* **environment** Can be used to set environment variables in the warmer lambda. You can also unset variables configured at the provider by setting them to undefined. However, you should almost never have to change the default. (defaults to unset all package level environment variables. )
|
|
74
75
|
* **tracing** Specify whether to enable/disable tracing at the function level. When tracing is enabled, warmer functions will use NPM to install the X-Ray client and use it to trace requests (It takes any of the values supported by serverless as `boolean`, `Active`or `PassThrough` and defaults to the provider-level setting)
|
|
75
76
|
* **verbose** If set to false, it disables the console.logs placed on this warmer lambda (defaults to `true`)
|
|
76
|
-
* **logRetentionInDays** Set the retention time in days for the log group associated to this warmer lamba
|
|
77
|
+
* **logRetentionInDays** Set the retention time in days for the log group associated to this warmer lamba. Can be any of the values specified in the [AWS documentation](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutRetentionPolicy.html#API_PutRetentionPolicy_RequestSyntax).
|
|
77
78
|
* **prewarm** If set to true, it warms up your lambdas right after deploying (defaults to `false`)
|
|
78
79
|
|
|
79
80
|
There are also some options which can be set under `custom.warmup.<yourWarmer>` to be applied to all your lambdas or under `yourLambda.warmup.<yourWarmer>` to overridde the global configuration for that particular lambda. Keep in mind that in order to configure a warmer at the function level, it needed to be previously configured at the `custom` section or the pluging will error.
|
|
@@ -110,7 +111,7 @@ custom:
|
|
|
110
111
|
timeout: 20
|
|
111
112
|
tracing: true
|
|
112
113
|
verbose: false # Disable the logs
|
|
113
|
-
logRetentionInDays:
|
|
114
|
+
logRetentionInDays: 14
|
|
114
115
|
prewarm: true # Run WarmUp immediately after a deploymentlambda
|
|
115
116
|
clientContext:
|
|
116
117
|
source: my-custom-source
|
|
@@ -255,7 +256,7 @@ The permissions can also be added to all lambdas using setting the role to `IamR
|
|
|
255
256
|
```yaml
|
|
256
257
|
provider:
|
|
257
258
|
name: aws
|
|
258
|
-
runtime:
|
|
259
|
+
runtime: nodejs16.x
|
|
259
260
|
iamRoleStatements:
|
|
260
261
|
- Effect: 'Allow'
|
|
261
262
|
Action:
|
|
@@ -267,6 +268,7 @@ custom:
|
|
|
267
268
|
default:
|
|
268
269
|
enabled: true
|
|
269
270
|
role: IamRoleLambdaExecution
|
|
271
|
+
architecture: 'arm64'
|
|
270
272
|
```
|
|
271
273
|
|
|
272
274
|
If setting `prewarm` to `true`, the deployment user used by the AWS CLI and the Serverless framework also needs permissions to invoke the warmer.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serverless-plugin-warmup",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Keep your lambdas warm during winter.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"eslint": "^8.5.0",
|
|
35
35
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
36
36
|
"eslint-plugin-import": "^2.24.2",
|
|
37
|
-
"husky": "^
|
|
38
|
-
"jest": "^
|
|
37
|
+
"husky": "^8.0.1",
|
|
38
|
+
"jest": "^28.1.3"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/config.js
CHANGED
|
@@ -20,6 +20,9 @@ function getWarmerConfig(config, defaultOpts) {
|
|
|
20
20
|
vpc: config.vpc === false ? { securityGroupIds: [], subnetIds: [] }
|
|
21
21
|
: (config.vpc !== undefined ? config.vpc : defaultOpts.vpc),
|
|
22
22
|
events: (Array.isArray(config.events)) ? config.events : defaultOpts.events,
|
|
23
|
+
architecture: (config.architecture !== undefined)
|
|
24
|
+
? config.architecture
|
|
25
|
+
: defaultOpts.architecture,
|
|
23
26
|
package: typeof config.package === 'object'
|
|
24
27
|
? {
|
|
25
28
|
individually: (config.package.individually !== undefined)
|
package/src/schema.js
CHANGED
|
@@ -94,6 +94,7 @@ function extendServerlessSchema(serverless) {
|
|
|
94
94
|
additionalProperties: false,
|
|
95
95
|
},
|
|
96
96
|
},
|
|
97
|
+
architecture: { enum: ['arm64', 'x86_64'] },
|
|
97
98
|
package: {
|
|
98
99
|
type: 'object',
|
|
99
100
|
properties: {
|
|
@@ -108,10 +109,7 @@ function extendServerlessSchema(serverless) {
|
|
|
108
109
|
environment: { $ref: '#/definitions/awsLambdaEnvironment' },
|
|
109
110
|
tracing: { $ref: '#/definitions/awsLambdaTracing' },
|
|
110
111
|
verbose: { type: 'boolean' },
|
|
111
|
-
logRetentionInDays: {
|
|
112
|
-
type: 'number',
|
|
113
|
-
enum: [1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653],
|
|
114
|
-
},
|
|
112
|
+
logRetentionInDays: { $ref: '#/definitions/awsLogRetentionInDays' },
|
|
115
113
|
prewarm: { type: 'boolean' },
|
|
116
114
|
};
|
|
117
115
|
|
package/src/warmer.js
CHANGED
|
@@ -222,7 +222,8 @@ function addWarmUpFunctionToService(service, warmerName, warmerConfig) {
|
|
|
222
222
|
handler: warmerConfig.pathHandler.split(path.sep).join(path.posix.sep),
|
|
223
223
|
memorySize: warmerConfig.memorySize,
|
|
224
224
|
name: warmerConfig.name,
|
|
225
|
-
|
|
225
|
+
...(warmerConfig.architecture ? { architecture: warmerConfig.architecture } : {}),
|
|
226
|
+
runtime: 'nodejs16.x',
|
|
226
227
|
package: warmerConfig.package,
|
|
227
228
|
timeout: warmerConfig.timeout,
|
|
228
229
|
...(Object.keys(warmerConfig.environment).length
|