serverless-plugin-warmup 7.3.0 → 8.1.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/README.md +10 -8
- package/package.json +2 -2
- package/src/config.js +1 -0
- package/src/schema.js +2 -4
- package/src/warmer.js +2 -1
package/README.md
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
[![npm monthly downloads][npm-downloads-badge]][npm-version-badge-url]
|
|
5
5
|
[](https://github.com/juanjoDiaz/serverless-plugin-warmup/actions/workflows/on-push.yaml)
|
|
6
6
|
[![Coverage Status][coveralls-badge]][coveralls-badge-url]
|
|
7
|
-
[](https://raw.githubusercontent.com/juanjoDiaz/serverless-plugin-warmup/
|
|
7
|
+
[](https://raw.githubusercontent.com/juanjoDiaz/serverless-plugin-warmup/main/LICENSE)
|
|
8
8
|
|
|
9
9
|
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:
|
|
@@ -63,18 +63,19 @@ The options are the same for all the warmers:
|
|
|
63
63
|
* **folderName** Folder to temporarily store the generated code (defaults to `.warmup`)
|
|
64
64
|
* **cleanFolder** Whether to automatically delete the generated code folder. You might want to keep it if you are doing some custom packaging (defaults to `true`)
|
|
65
65
|
* **name** Name of the generated warmer lambda (defaults to `${service}-${stage}-warmup-plugin-${warmerName}`)
|
|
66
|
+
* **roleName** Name to be applied to the default warmer lambda role. Ignored if a the role setting is used (defaults to `${service.service}-${stage}-${region}-${warmerName.toLowerCase()}-role`)
|
|
66
67
|
* **role** Role to apply to the warmer lambda (defaults to the role in the provider)
|
|
67
68
|
* **tags** Tag to apply to the generated warmer lambda (defaults to the serverless default tags)
|
|
68
69
|
* **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
70
|
* **memorySize** The memory to be assigned to the warmer lambda (defaults to `128`)
|
|
70
71
|
* **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 `
|
|
72
|
+
* **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`)
|
|
72
73
|
* **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}/**'] }`)
|
|
73
74
|
* **timeout** How many seconds until the warmer lambda times out. (defaults to `10`)
|
|
74
75
|
* **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. )
|
|
75
76
|
* **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)
|
|
76
77
|
* **verbose** If set to false, it disables the console.logs placed on this warmer lambda (defaults to `true`)
|
|
77
|
-
* **logRetentionInDays** Set the retention time in days for the log group associated to this warmer lamba
|
|
78
|
+
* **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).
|
|
78
79
|
* **prewarm** If set to true, it warms up your lambdas right after deploying (defaults to `false`)
|
|
79
80
|
|
|
80
81
|
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.
|
|
@@ -95,6 +96,7 @@ custom:
|
|
|
95
96
|
cleanFolder: false
|
|
96
97
|
memorySize: 256
|
|
97
98
|
name: warmer-default
|
|
99
|
+
roleName: my-custom-role
|
|
98
100
|
role: WarmupRole
|
|
99
101
|
tags:
|
|
100
102
|
Project: foo
|
|
@@ -111,7 +113,7 @@ custom:
|
|
|
111
113
|
timeout: 20
|
|
112
114
|
tracing: true
|
|
113
115
|
verbose: false # Disable the logs
|
|
114
|
-
logRetentionInDays:
|
|
116
|
+
logRetentionInDays: 14
|
|
115
117
|
prewarm: true # Run WarmUp immediately after a deploymentlambda
|
|
116
118
|
clientContext:
|
|
117
119
|
source: my-custom-source
|
|
@@ -610,8 +612,8 @@ This software is released under the MIT license. See [the license file](LICENSE)
|
|
|
610
612
|
[npm-version-badge]: https://badge.fury.io/js/serverless-plugin-warmup.svg
|
|
611
613
|
[npm-version-badge-url]: https://www.npmjs.com/package/serverless-plugin-warmup
|
|
612
614
|
[npm-downloads-badge]: https://img.shields.io/npm/dm/serverless-plugin-warmup.svg
|
|
613
|
-
[coveralls-badge]: https://coveralls.io/repos/juanjoDiaz/serverless-plugin-warmup/badge.svg?branch=
|
|
614
|
-
[coveralls-badge-url]: https://coveralls.io/r/juanjoDiaz/serverless-plugin-warmup?branch=
|
|
615
|
+
[coveralls-badge]: https://coveralls.io/repos/juanjoDiaz/serverless-plugin-warmup/badge.svg?branch=main
|
|
616
|
+
[coveralls-badge-url]: https://coveralls.io/r/juanjoDiaz/serverless-plugin-warmup?branch=main
|
|
615
617
|
|
|
616
618
|
## Acknowledgements
|
|
617
619
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serverless-plugin-warmup",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "Keep your lambdas warm during winter.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
36
36
|
"eslint-plugin-import": "^2.24.2",
|
|
37
37
|
"husky": "^8.0.1",
|
|
38
|
-
"jest": "^
|
|
38
|
+
"jest": "^29.1.2"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/config.js
CHANGED
|
@@ -15,6 +15,7 @@ function getWarmerConfig(config, defaultOpts) {
|
|
|
15
15
|
pathHandler: path.join(folderName, 'index.warmUp'),
|
|
16
16
|
cleanFolder: (typeof config.cleanFolder === 'boolean') ? config.cleanFolder : defaultOpts.cleanFolder,
|
|
17
17
|
name: (config.name !== undefined) ? config.name : defaultOpts.name,
|
|
18
|
+
roleName: (config.roleName !== undefined) ? config.roleName : defaultOpts.roleName,
|
|
18
19
|
role: (config.role !== undefined) ? config.role : defaultOpts.role,
|
|
19
20
|
tags: (config.tags !== undefined) ? config.tags : defaultOpts.tags,
|
|
20
21
|
vpc: config.vpc === false ? { securityGroupIds: [], subnetIds: [] }
|
package/src/schema.js
CHANGED
|
@@ -15,6 +15,7 @@ function extendServerlessSchema(serverless) {
|
|
|
15
15
|
folderName: { type: 'string' },
|
|
16
16
|
cleanFolder: { type: 'boolean' },
|
|
17
17
|
name: { type: 'string' },
|
|
18
|
+
roleName: { type: 'string' },
|
|
18
19
|
role: { $ref: '#/definitions/awsLambdaRole' },
|
|
19
20
|
tags: { $ref: '#/definitions/awsResourceTags' },
|
|
20
21
|
vpc: {
|
|
@@ -109,10 +110,7 @@ function extendServerlessSchema(serverless) {
|
|
|
109
110
|
environment: { $ref: '#/definitions/awsLambdaEnvironment' },
|
|
110
111
|
tracing: { $ref: '#/definitions/awsLambdaTracing' },
|
|
111
112
|
verbose: { type: 'boolean' },
|
|
112
|
-
logRetentionInDays: {
|
|
113
|
-
type: 'number',
|
|
114
|
-
enum: [1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653],
|
|
115
|
-
},
|
|
113
|
+
logRetentionInDays: { $ref: '#/definitions/awsLogRetentionInDays' },
|
|
116
114
|
prewarm: { type: 'boolean' },
|
|
117
115
|
};
|
|
118
116
|
|
package/src/warmer.js
CHANGED
|
@@ -26,7 +26,7 @@ function addWarmUpFunctionRoleToResources(service, stage, warmerName, warmerConf
|
|
|
26
26
|
Type: 'AWS::IAM::Role',
|
|
27
27
|
Properties: {
|
|
28
28
|
Path: '/',
|
|
29
|
-
RoleName: {
|
|
29
|
+
RoleName: warmerConfig.roleName || {
|
|
30
30
|
'Fn::Join': [
|
|
31
31
|
'-',
|
|
32
32
|
[
|
|
@@ -233,6 +233,7 @@ function addWarmUpFunctionToService(service, warmerName, warmerConfig) {
|
|
|
233
233
|
...(warmerConfig.logRetentionInDays !== undefined
|
|
234
234
|
? { logRetentionInDays: warmerConfig.logRetentionInDays }
|
|
235
235
|
: {}),
|
|
236
|
+
...(warmerConfig.roleName ? { roleName: warmerConfig.roleName } : {}),
|
|
236
237
|
...(warmerConfig.role ? { role: warmerConfig.role } : {}),
|
|
237
238
|
...(warmerConfig.tags ? { tags: warmerConfig.tags } : {}),
|
|
238
239
|
...(warmerConfig.vpc ? { vpc: warmerConfig.vpc } : {}),
|