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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠