How to add log retention for cdk API gateway execution log?

0

I have created an API using CDK and enabled execution log. I am not able to get a solution to add log retention for execution log. Yes, we can use access log with log retention, but I just wanted to know is there any way I can add log retention for execution log? please help with your valuable suggestion.

const api = new RestApi(this, MyAPI, { deployOptions: { stageName: 'dev', dataTraceEnabled: true, tracingEnabled: true, loggingLevel: MethodLoggingLevel.INFO, }, cloudWatchRole: true });

1回答
0

Hi,

Yes, you have a parameter named retention in the class LogRetention of CDK: see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.LogRetention.html.

Put here the number that you want.

This blog post will show you how to do that form the API Gateway Construct: https://www.kevinwmcconnell.com/cdk/http-api-logs-with-cdk

Best,

Didier

profile pictureAWS
エキスパート
回答済み 8ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ