7
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

serverless.yml "logRetentionInDays" に指定できる期間について

Last updated at Posted at 2018-05-16

以下の記事を見て serverless.ymlのLambdaのログの保持期間をコスト最適化のため設定したく

logRetentionInDays: 10 (10日間)を指定してデプロイしたら
以下のエラーになった話。英語ちゃんと読まず20分失ったので備忘します。

◆デプロイ時のエラー

$ sls deploy
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service .zip file to S3 (16.87 MB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
Serverless: Operation failed!
 
  Serverless Error ---------------------------------------
 
  An error occurred: xxxLogGroup - Invalid retention value. Valid values are: [1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653] (Service: AWSLogs; Status Code: 400; Error Code: InvalidParameterException; Request ID: 1003f64c-58ff-11e8-a940-ff156e85d74b).
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           8.10.0
     Serverless Version:     1.27.0

エラー内容を見ると、logRetentionInDaysに指定できる期間は決まっているらしい。

[1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653]

とのことなので、1週間にして再デプロイしたら上手く行った。

◆修正後のプロパティ

serverles.yml
provider:
  logRetentionInDays: 7

参考: CloudWatchLogsのAPIにも指定できる日付記載あり

--retention-in-days (integer)

The number of days to retain the log events in the specified log group. Possible values are: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653.

指定できる値は同じですね。

以上です。

7
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?