Skip to content

Region name in Object URL

0

I had shared Object URL with public, and it used to work fine with Object URL (which I had copied from AWS Console - Object URL of the document under the Properties). For example: https://mybucktname.s3.amazonaws.com/myfolder/myfile.htm Recently, AWS is returning "Access Denied" error.

When I checked the object properties again, the Object URL is specified as follows (includes region name) For example: https://mybucktname.s3.us-east-1.amazonaws.com/myfolder/myfile.htm And this works fine in the browser.

So it appears that the region name must be included in the Object URL.

However, some Object URLs of documents in some other buckets in the same region still work fine without region name in the URL. Although for these documents, when I see Object URL in the console, I see region name included in the URL, and such URLs are also loading in browser without error.

AFAIK, my all buckets have exactly same properties and permissions. I am wondering why Object URL without region name for a document in one bucket returns error, while other documents in other similar buckets give no error both Object URLs (i.e. without and with region name in it).

Note, the buckets are not configured as static website. I could not find AWS document that describes Object URL usage for buckets which are not static websites.

What I am missing?

asked 2 years ago784 views

2 Answers
0

The behavior you're experiencing is related to changes in Amazon S3 URL formats and endpoint configurations. Here's what might be happening:

  1. Legacy vs. Regional Endpoints: AWS has been moving towards using regional endpoints for S3 buckets. The URL format without the region (https://mybucketname.s3.amazonaws.com/...) is considered a legacy global endpoint, while the one with the region (https://mybucketname.s3.us-east-1.amazonaws.com/...) is a regional endpoint.

  2. Bucket Creation Date: The difference in behavior you're seeing between buckets might be due to when these buckets were created. Buckets created after a certain date (around March 20, 2019) in most regions require the use of regional endpoints.

  3. Temporary Redirects: In some cases, when you use the legacy endpoint for newer buckets or in certain regions, you might receive a temporary redirect (HTTP 307) to the correct regional endpoint. This redirect might be happening transparently for some of your buckets, making it appear as if the legacy URL still works.

  4. Best Practice: AWS recommends always using the regional endpoints with the region code in the hostname. This is considered more reliable and future-proof.

  5. Bucket Configuration: While you mention that all your buckets have the same properties and permissions, there might be subtle differences in their configurations or the time they were created that affect this behavior.

  6. Public Access: Ensure that the bucket and object permissions allow public access if you intend for these URLs to be publicly accessible.

To resolve this issue and ensure consistency:

  1. Always use the regional endpoint format for your S3 URLs.
  2. Double-check your bucket and object permissions to ensure they allow the intended access.
  3. If you need to support legacy URLs, you might need to implement a redirection mechanism on your application side.

Remember that using presigned URLs or configuring buckets as static websites provides more control over URL formats and access, which might be worth considering depending on your use case.
Sources
Community | Format and Parse Amazon S3 URLs
Sharing objects with presigned URLs - Amazon Simple Storage Service

answered 2 years ago

  • All buckets were created in Aug. 2021. In other buckets, both the Object URLs with and without region name are loading without any redirection. (Browser's Network inspection shows Status 200.)

    I had read somewhere that us-east-1 region has some special/different treatment. All my buckets are in us-east-1.

    I understand that I must move on to start using regional end points for all documents. I am just trying to understand the reason behind current behavior/observation of a specific bucket.

0

Hi,

This usually comes from an ACL issue (which is different from policy): https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html

It happens very frequently when you replicate objects from 1 bucket to the other with tools like AWS DataSync: the replica keeps the original ownership and you start having auth issues. The page above will explain you how to fix it.

Best,

Didier

EXPERT

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.