Search code examples
restamazon-web-servicesamazon-s3eventual-consistency

S3 Wait function on direct resource access?


Is there any way to tell S3 to wait for an object before responding? I want to do this directly against the S3 endpoint via an HTTP(S) request.

I understand this function exists in the PHP SDK http://docs.aws.amazon.com/aws-sdk-php/v2/guide/feature-waiters.html#

But can you apply this wait functionality when downloading a resource directly from the S3 endpoint? (without an SDK)?


Solution

  • The answer is yes, but not really.

    Yes, because everything the SDK can do can be done with your own code, because the SDK uses the same documented public APIs to access the services... the SDKs have no privileged interface... but, then again, not really, because the waiter logic is pretty much an illusion, a convenient fiction. It's not waiting for the service in a "tell me when you're ready" sense... it's really just polling the service to check the state of the resource in question. They're just a convenience so you don't have to write your own polling retry logic.

    So, sure you can... but to do it, you just have to keep asking until you get the response you expect... which I assume is not the answer you were hoping for.

    When you say "wait for an object," though, a new object (not an overwrite) should be available as soon as the PUT returns success. Overwrites and deletions are eventually-consistent, but new object consistency is immediate.

    One exception to this is in the us-east-1 region of S3 where immediate consistency is only officially provided if you use the s3-external-1.amazonaws.com or s3.dualstack.us-east-1.amazonaws.com endpoints, not the s3.amazonaws.com endpoint.