Skip to content

Commit

Permalink
Add explanatory comment
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewHepburn authored and dekobon committed Mar 1, 2023
1 parent 214bfed commit e6bbcc5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions common/etc/nginx/include/s3gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ async function fetchCredentials(r) {

if (current) {
// If AWS returns a Unix timestamp it will be in seconds, but in Date constructor we should provide timestamp in milliseconds
// In some situations (including EC2 and Fargate) current.expiration will be an RFC 3339 string - see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#instance-metadata-security-credentials
const expireAt = typeof current.expiration == 'number' ? current.expiration * 1000 : current.expiration
const exp = new Date(expireAt).getTime() - maxValidityOffsetMs;
if (NOW.getTime() < exp) {
Expand Down

0 comments on commit e6bbcc5

Please sign in to comment.