5

I want to serve assets to the internet. I have created a public bucket with website hosting enabled.

I have discovered several kinds of URLs supported by AWS:

# HTTP + HTTPS
https://<bucket>.s3.amazonaws.com/<file>

# HTTP only!
http://<bucket>.s3-website-<region>.amazonaws.com/<file>

# HTTP + HTTPS
# Will be removed
# See https://forums.aws.amazon.com/ann.jspa?annID=6776
https://s3.<region>.amazonaws.com/<bucket>/<file>

Why are there so many formats and which one is preferred?

From my POV the first URL is simpler and supports HTTPS so it is better IMO, but are there downsides to using it?

Matthieu Napoli
  • 421
  • 1
  • 5
  • 11

2 Answers2

4

The first and third are REST URLs and the second one is a Website URL - they can both be served from the same bucket but behave slightly differently and have different purpose. See Key Differences Between the Amazon Website and the REST API Endpoint.

I don’t believe the 3rd form will be removed anytime soon (AWS is very conservative with deprecating existing things) but it’t not the recommended way because it in fact in some cases redirects to the first form. If you directly use the first form you save yourself a redirect.

Hope that helps :)

MLu
  • 24,849
  • 5
  • 59
  • 86
  • 3
    AWS quietly [announced](https://forums.aws.amazon.com/ann.jspa?annID=6776) last week that path-style URLs are deprecated and will stop working in late 2020. It's thrown the community into confused disbelief, since the HTTPS REST endpoints for buckets with dots in the name can only be accessed using path-style URLs. – Michael - sqlbot May 05 '19 at 12:48
  • @Michael-sqlbot Interesting, thanks! I missed that "announcement" even though ironically I spent the last week at AWS Summit in Sydney. – MLu May 05 '19 at 22:07
  • The backlash seems to have prompted AWS to partially withdraw the deprecation. Only new buckets will be impacted. https://aws.amazon.com/blogs/aws/amazon-s3-path-deprecation-plan-the-rest-of-the-story/ – Michael - sqlbot May 09 '19 at 00:53
1

Yes, if you want to do something across the regions it is difficult to manage the url with code, so choose something which is easy to code. Whenever you want to refer the different region s3 bucket you need not to create different url. Since path based url going to retired my preference will be a url which contain region too. Assume case

url = http://<bucket>.s3-website-<region>.amazonaws.com/

from this url I can refer buckets in different regions, which is helpful if you need bucket similar url across the regions. Also it depend on use cases too.

asktyagi
  • 2,860
  • 2
  • 8
  • 25