Download RDS logs

The easer way to grab your RDS logs

db_instance="awesome_db_identifier"
aws_profile="corp_aws_profile"

for logfile in $(aws --profile=${aws_profile} rds describe-db-log-files --db-instance-identifier ${db_instance} --query "DescribeDBLogFiles[].LogFileName"  |jq -r '.|@sh'); do
  echo $logfile
  name=$(echo $logfile|tr -d "'")
  aws rds --profile=${aws_profile} download-db-log-file-portion --db-instance-identifier ${db_instance} --log-file-name "${name}" --starting-token 0 --output text >> $(echo "${name}" |tr '/' '_').log
done