Delete log groups with zero bytes
# get all log groups
aws logs describe-log-groups| in2csv -f json --key logGroups > logs.csv
# R
# read log groups and filter to only those that have storedBytes == 0
read_csv("logs.csv",
col_types = cols_only(storedBytes = col_integer(), creationTime = col_double(), logGroupName = col_character())) %>%
mutate(creationTime = as.POSIXct(creationTime/1000, origin="1970-01-01")) %>%
filter(storedBytes ==0) %>%
select(logGroupName) %>%
write_tsv("logs_clear.txt", col_names = F)
# delete log groups with storedBytes == 0
parallel aws logs delete-log-group --log-group-name {1} :::: logs_clear.txt
# you might see
# An error occurred (ThrottlingException) when calling the DeleteLogGroup operation (reached max retries: 4): Rate exceeded