---
title: "Comment by Manish Gautam on \"Set AWS Cloudwatch log groups Retention Policy for all Log  using python boto3 script\" | Hashnode"
description: "Great article. But I need to apply the retention policy only to those log group whose retention days is more then 30 days. Please help"
url: "https://hashnode.com/posts/set-aws-cloudwatch-log-groups-retention-policy-for-all-log-using-python-boto3-script/61362fc5e9421a617c32f157/comment/62b9e837f2e6c7d70c1244d5"
---

[Discussion](https://hashnode.com/posts/set-aws-cloudwatch-log-groups-retention-policy-for-all-log-using-python-boto3-script/61362fc5e9421a617c32f157)

Comment [Set AWS Cloudwatch log groups Retention Policy for all Log using python boto3 script](https://hashnode.com/posts/set-aws-cloudwatch-log-groups-retention-policy-for-all-log-using-python-boto3-script/61362fc5e9421a617c32f157)

[Manish Gautam](https://hashnode.com/@GAUTAM67)

[Jun 27, 2022](https://hashnode.com/posts/set-aws-cloudwatch-log-groups-retention-policy-for-all-log-using-python-boto3-script/61362fc5e9421a617c32f157/comment/62b9e837f2e6c7d70c1244d5)

Great article. But I need to apply the retention policy only to those log group whose retention days is more then 30 days. Please help

[Dheeraj Choudhary](https://hashnode.com/@Dheeraj-Choudhary)

[Jun 27, 2022](https://hashnode.com/posts/set-aws-cloudwatch-log-groups-retention-policy-for-all-log-using-python-boto3-script/61362fc5e9421a617c32f157/comment/62b9e837f2e6c7d70c1244d5#reply-62b9f289f2e6c7d70c124637)

response = client.describe\_log\_groups() will return below dictionary as seen below { 'logGroups': \[ { 'logGroupName': 'string', 'creationTime': 123, 'retentionInDays': 123, 'metricFilterCount': 123, 'arn': 'string', 'storedBytes': 123, 'kmsKeyId': 'string' }, \], 'nextToken': 'string' } The way I iterated through this dict response using for loop to fetch loggroupname and append in list same way do it for retention days and append it to dictionary, then based on key value run conditions to execute program
