serverless-provisioned-concurrency-autoscaling
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -18,5 +18,9 @@ "use strict"; | ||
const Target = this.name.target(this.data.function); | ||
const DependsOn = [Target, this.name.PCAliasLogicalId(this.data.function)].concat(this.dependencies); | ||
const metricSpecificationJson = this.data.customMetric ? | ||
this.customMetricJson(this.data.customMetric) : this.predfinedMetricJson(); | ||
const DependsOn = [ | ||
Target, | ||
this.name.PCAliasLogicalId(this.data.function), | ||
].concat(this.dependencies); | ||
const metricSpecificationJson = this.data.customMetric | ||
? this.customMetricJson(this.data.customMetric) | ||
: this.predfinedMetricJson(); | ||
return { | ||
@@ -39,3 +43,3 @@ [PolicyName]: { | ||
PredefinedMetricType: 'LambdaProvisionedConcurrencyUtilization', | ||
} | ||
}, | ||
}; | ||
@@ -46,8 +50,11 @@ } | ||
CustomizedMetricSpecification: { | ||
Dimensions: (customMetric.dimensions || []).map(d => ({ Name: d.name, Value: d.value })), | ||
Dimensions: (customMetric.dimensions || []).map((d) => ({ | ||
Name: d.name, | ||
Value: d.value, | ||
})), | ||
MetricName: customMetric.metricName, | ||
Namespace: customMetric.namespace, | ||
Statistic: utility_1.ucfirst(customMetric.statistic || ""), | ||
Unit: customMetric.unit | ||
} | ||
Statistic: utility_1.ucfirst(customMetric.statistic || ''), | ||
Unit: customMetric.unit, | ||
}, | ||
}; | ||
@@ -54,0 +61,0 @@ } |
@@ -48,2 +48,7 @@ "use strict"; | ||
}; | ||
const schema = { | ||
properties: { | ||
concurrencyAutoscaling: { type: ['boolean', 'object'] }, | ||
}, | ||
}; | ||
class Plugin { | ||
@@ -53,2 +58,6 @@ constructor(serverless) { | ||
this.serverless = serverless; | ||
if (this.serverless.configSchemaHandler && | ||
this.serverless.configSchemaHandler.defineFunctionProperties) { | ||
this.serverless.configSchemaHandler.defineFunctionProperties('aws', schema); | ||
} | ||
this.hooks = { | ||
@@ -67,4 +76,7 @@ 'package:compileEvents': this.beforeDeployResources.bind(this), | ||
defaults(config) { | ||
const customMetricConfig = config.customMetric ? | ||
{ customMetric: this.customMetricDefaults(config.customMetric, config.name) } : {}; | ||
const customMetricConfig = config.customMetric | ||
? { | ||
customMetric: this.customMetricDefaults(config.customMetric, config.name), | ||
} | ||
: {}; | ||
return Object.assign({ maximum: config.maximum || 10, minimum: config.minimum || 1, scaleInCooldown: config.scaleInCooldown || 120, scaleOutCooldown: config.scaleOutCooldown || 0, usage: config.usage || 0.75, function: config.function, name: config.name }, customMetricConfig); | ||
@@ -75,9 +87,9 @@ } | ||
{ | ||
name: "FunctionName", | ||
name: 'FunctionName', | ||
value: functionName, | ||
}, | ||
{ | ||
name: "Resource", | ||
name: 'Resource', | ||
value: `${functionName}:provisioned`, | ||
} | ||
}, | ||
]; | ||
@@ -84,0 +96,0 @@ return { |
{ | ||
"name": "serverless-provisioned-concurrency-autoscaling", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Serverless Plugin for AWS Lambdas Provisioned Concurrency Auto Scaling configuration.", | ||
@@ -22,2 +22,3 @@ "main": "./lib/index.js", | ||
"lint": "eslint . --ext .ts,.tsx", | ||
"lint:fix": "eslint . --ext .ts,.tsx --fix", | ||
"test": "jest --silent", | ||
@@ -56,3 +57,3 @@ "test:coverage": "jest --coverage --silent", | ||
"@types/node": "^14.0.27", | ||
"@types/serverless": "^1.72.5", | ||
"@types/serverless": "^1.78.13", | ||
"@typescript-eslint/eslint-plugin": "^3.8.0", | ||
@@ -59,0 +60,0 @@ "@typescript-eslint/parser": "^3.8.0", |
@@ -28,3 +28,3 @@  | ||
Add `concurrencyAutoscaling` parameters under each function you wish to autoscale in your `serverless.yml`. | ||
Add `concurrencyAutoscaling` parameters under each function you wish to autoscale in your `serverless.yml`. | ||
@@ -42,3 +42,3 @@ Add `customMetric: true` if you want to use `Maximum` instead of `Average` statistic. | ||
# full configuration | ||
# full configuration | ||
@@ -45,0 +45,0 @@ world: |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
41283
353