#coding:utf-8 import boto3 log_client = boto3.client('logs',region_name = 'cn-north-1') log_list = log_client.describe_log_groups() print(log_list) for l in log_list['logGroups']: response = log_client.put_retention_policy(logGroupName=l['logGroupName'],retentionInDays=30) print("保留期设置:",response)
参考文档:https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/logs.html#CloudWatchLogs.Client.delete_resource_policy