in reply to Need to print bucket and filename which is uploaded on S3 storage

The ->buckets method returns undef on error. So you have an error.

Look at the ->err and ->errstr methods for the error message.