zoukankan      html  css  js  c++  java
  • 设置各区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

  • 相关阅读:
    tkinter 类继承的三种方式
    tkinter 的两个例子
    python 测试驱动开发的简单例子
    python 播放 wav 文件
    Python 操作 MongoDB
    【转】如何拿到半数面试公司Offer——我的Python求职之路
    scrapy 保存到 sqlite3
    scrapy 爬取 useragent
    收集的User-Agent
    scrapy 登录
  • 原文地址:https://www.cnblogs.com/husbandmen/p/10656197.html
Copyright © 2011-2022 走看看