Log retention deletion when a new log groups gets created

0

Hi Everyone,

Need a lambda function to delete the log groups, here we have event bridge rule when a new log group gets created lambda should validate whether there is a retention period is set or not if not then we need to delete that log group

1 Respuesta
1

Hi, the AWS API has everything you need. Write your Lambda using an AWS API SDK (e.g. Boto3 for Python) and call the following actions: https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_DescribeLogGroups.html https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_DeleteLogGroup.html I hope this helps!

EXPERTO
respondido hace un año
  • To add to the above API call using boto3 you also need to have Lambda execution role(IAM role) to include below permissions to delete the log group and log streams

    { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "logs:deleteLogGroup", "logs:deleteLogStream" ], "Resource": [ "arn:aws:logs:::*" ] } ] }

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas