Skip to main content

Posts

Showing posts from February, 2022

Python script to list all AWS CloudWatch logs with their retention time

The following Python script will help you to export list of any all the CloudWatch logs with their retention time and size of the log group an AWS account. The script also helps you to save the output within CSV file. #!/usr/bin/env python3.8 #This script will save the list of CloudWatch log group names, their retention time and # size (in MBs) in to CSV file import boto3 import time import csv # Setting up AWS profile and region profile = "default" region = "us-east-1" session = boto3 . Session ( profile_name = profile , region_name = region ) #getting current date and time date_time = time . strftime ( " %d %m%Y_%H%M" ) # setting up file name fname = "CloudWatch-Logs_" ftime = date_time fext = ".csv" filename = fname + ftime + fext # open file to write output with open ( filename , 'w' ) as f :     print ( 'Profile, Region,Log Group Name, Retention Time (in days), Size (in MB)' , file = f )   cw_logs =

Python Script to list all open Pull requests from AWS CodeCommit repositories

The following Python script will help to export list of any open pull requests from CodeCommit repositories from an AWS account. The output will be saved within CSV file. #!/usr/bin/env python3.8 # This script is used to find out any open pull requests from all the repositories # from an account and write output to the csv file # Importing boto3, csv and time module import boto3 import csv import time # Setting up AWS profile and region profile = "default" region = "us-east-1" session = boto3 . Session ( profile_name = profile , region_name = region ) repo_client = session . client ( 'codecommit' ) repos = repo_client .list_repositories(     sortBy = 'repositoryName' ) repo_list = repos repo_name = repo_list [ 'repositories' ] # Getting current date and time date_time = time . strftime ( " %d %m%Y_%H%M%S" ) # Setting up file name fname = "Open_PullReqsIDs_" ftime = date_time fext = ".csv" filename