1

I want to generate pre-signed S3 links for existing objects in the bucket in bulk.

To achieve this, I can run S3.getSignedUrl() in a loop but I am not sure if this function runs locally or makes an API call to AWS.

This post says it is done locally, but this is not mentioned anywhere in the documentation.

How can I verify that it doesn't make an external API call?

I am using aws-sdk-js package.

I went through the actual implementation of the getSignedUrl from the SDK:

function getSignedUrl(operation, params, callback) {
    params = AWS.util.copy(params || {});
    var expires = params.Expires || 900;

    if (typeof expires !== 'number') {
      throw AWS.util.error(new Error(),
        { code: 'InvalidParameterException', message: 'The expiration must be a number, received ' + typeof expires });
    }

    delete params.Expires; // we can't validate this
    var request = this.makeRequest(operation, params);

    if (callback) {
      AWS.util.defer(function() {
        request.presign(expires, callback);
      });
    } else {
      return request.presign(expires, callback);
    }
  }

Here, a request is being created. Does it make an external API call?

Ermiya Eskandary
  • 15,323
  • 3
  • 31
  • 44
confusedWarrior
  • 938
  • 2
  • 14
  • 30
  • It *is* running locally. It just produces a cryptographic signature based on your API credentials. Otherwise it would be called something-something-token, which produces a token on the AWS server. – deceze Nov 29 '21 at 09:14
  • @deceze How can check if it runs locally? I mean the function doesn't call external api? Is there any way to verify? Doesn't it validate s3 credentials before generating the url? – confusedWarrior Nov 29 '21 at 09:15
  • Worst case: benchmark it and compare how much time it takes compared to a request that you know makes a network request. Perhaps disconnect your internet connection and see if it still works… – deceze Nov 29 '21 at 09:25
  • @deceze That's an option. Can we verify checking code or the implementation of the method? Or is there any documentation that supports your statement? – confusedWarrior Nov 29 '21 at 09:26

0 Answers0