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 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南