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 Antwort
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
EXPERTE
beantwortet vor 8 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen