aws/aws-sdk-ruby — pull request #117 by xli (2013-01-04 19:30:32+00:00)
Title: auto refresh EC2 credential provider when the credential is expired

=== The problem ===

S3Object signs a url for accessing S3 file locally (S3Object#url_for), which does not fire any request to AWS service. When using the aws iam role instance credential on ec2 instance, the S3Object#url_for may return an security token expired url if the credential is expired.
The auto refresh credential basing on token expire error respond from server will not work well in this case because no request is sent out.
S3Object#exits? also return false when the temp credentials got from ec2 instance metadata is expired.

=== The fix ===

Base on document: http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/UsingIAM.html#UsingIAMrolesWithAmazonEC2Instances

"AWS access keys on an EC2 instance are rotated automatically multiple times a day. New access keys will be made available at least five minutes prior to the expiration of the old access keys."

Make EC2 credential provider refresh the cached credential when the credential is going to expired within 5 min.
The DefaultProvider is also caching the credential, so have to change it to not cache the credential.