【AWS CLI】download-db-log-file-portion command execution error

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

When downloading the RDS log file using the download-db-log-file-portion AWS CLI command, the following error may occur.

execution command

$ aws rds download-db-log-file-portion --db-instance-identifier ${db-instance-identifier} --log-file-name ${logfile} > ${output}.log

error

An error occurred (InvalidParameterValue) when calling the DownloadDBLogFilePortion operation: This file contains binary data and should be downloaded instead of viewed.

We explain the root cause and workaround below.

Cause

Downloading fails when there are multibyte characters or binary data contained in the log. It's a known aws-cli issues.

Workaround

We can work around the issue by using the deprecated RDS CLI instead of the AWS CLI.

RDS REST API Reference | The rds-download-db-logfile Command

You can also download complete og files using the rds-download-db-logfile command. Because the AWS CLI does not currently support the rds-download-db-logfile command, you must use the deprecated RDS CLI to run the rds-download-db-logfile command. You can get the last version of the RDS CLI in a ZIP file at http://s3.amazonaws.com/rds-downloads/RDSCli.zip.

Using rds-download-db-logfile command

$ rds-download-db-logfile ${db-instance-identifier} --log-file-name ${logfile} > ${output}.log

Conclusion

In this post, we explained the root cause and workaround for one error that may occur when downloading RDS log files using the download-db-log-file-portion AWS CLI command. Please use this workaround until rds-download-db-logfile is supported in the AWS CLI.

References