• 设置各区cloudwatch 日志组的保留期为30天


    一、海外区

    #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

  • 相关阅读:
    OCS 2007 R2下载资源整理
    Windows Server 2012 R2 WSUS 4.0 加速
    JavaScript入门(三)
    JavaScript入门(一)
    JavaScript入门(二)
    CSS基础
    古董代码
    自我介绍
    Android Activity的加载的模式
    Android 数字签名
  • 原文地址:https://www.cnblogs.com/husbandmen/p/10656197.html
Copyright © 2020-2023  润新知