一、海外区

#coding:utf-8
import boto3
region = ['us-east-1','us-east-2','us-west-1','us-west-2','ap-south-1','ap-southeast-1','ap-southeast-2','ap-northeast-2','ap-northeast-1','ca-central-1','eu-central-1','eu-west-1','eu-west-2','eu-west-3','eu-north-1','sa-east-1']
for r in region:
    log_client = boto3.client('logs',region_name = r)
    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)

 

 

 

二、中国区

#coding:utf-8
import boto3
region = ['cn-northwest-1','cn-north-1']
for r in region:
    log_client = boto3.client('logs',region_name = r)
    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

 

相关文章:

  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
  • 2022-03-08
  • 2021-09-27
  • 2021-06-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-08
  • 2021-08-19
  • 2022-12-23
  • 2022-01-12
  • 2021-12-16
  • 2022-12-23
相关资源
相似解决方案