Skip to content

Commit ef21aa7

Browse files
author
Artificer Entertainment
committed
Fixes based on testing.
1 parent d9e510e commit ef21aa7

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

add-log-retention.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const nco = require('nco');
44
const semver = require('semver');
55

6+
//values from http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutRetentionPolicy.html
67
const validRetentionInDays = [1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653];
78

89
class AwsAddLogRetention {
@@ -42,7 +43,7 @@ class AwsAddLogRetention {
4243
if(localLogRentationInDays === null && globalLogRetentionInDays === null) {
4344
return;
4445
}
45-
const functionLogRetentionInDays = localLogRentationInDays === null ? globalLogRetentionInDays : sanitizeRetentionValue(localLogRentationInDays);
46+
const functionLogRetentionInDays = localLogRentationInDays === null ? globalLogRetentionInDays : this.sanitizeRetentionValue(localLogRentationInDays);
4647
const logGroupLogicalId = this.provider.naming.getLogGroupLogicalId(functionName);
4748

4849
const resource = {
@@ -57,8 +58,8 @@ class AwsAddLogRetention {
5758

5859
beforeDeploy() {
5960
const service = this.serverless.service;
60-
const globalLogRetentionInDays = service.provider && service.provider.logRetentionInDays
61-
? sanitizeRetentionValue(service.provider.logRetentionInDays)
61+
const globalLogRetentionInDays = service.custom && service.custom.logRetentionInDays
62+
? this.sanitizeRetentionValue(service.custom.logRetentionInDays)
6263
: null;
6364
this.addLogRetentionForFunctions(globalLogRetentionInDays);
6465
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-plugin-log-retention",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Control the retention of your function's cloudwatch logs.",
55
"main": "add-log-retention.js",
66
"scripts": {

0 commit comments

Comments
 (0)