Format and Parse Amazon S3 URLs
Find the right Amazon S3 URL
s3:
, http:
, or https:
. Then, there are the ones with s3.amazonaws.com
, s3.us-east-1.amazonaws.com
, or even s3-us-west-2.amazonaws.com
(note the dash instead of the dot between s3 and the region code). And where do you put the bucket: is it <bucket>.s3.us-east-1.amazonaws.com/<key>
or s3.us-east-1.amazonaws.com/<bucket>/<key>
? And when it comes to static website hosting, of course, there is also <bucket>.s3-website-us-east-1.amazonaws.com
and <bucket>.s3-website-us-east-1.amazonaws.com
(again, note the dash and the dot).s3://<bucket>/<key>
. This URL is also displayed by the AWS management console.
us-east-1
have a legacy global endpoint that doesn't need a region code in the hostname:-
instead of a dot .
between s3
and <region>
:us-west-2
region would support the legacy dash-style URL like https://s3-us-west-2.amazonaws.com/<bucket>/<key>
. Nevertheless, the standard format https://s3.us-west-2.amazonaws.com/<bucket>/<key>
is also available for these outliers.s3.amazonaws.com
or s3.<region>.amazonaws.com
hostname, but more importantly, they support secure HTTPS connections. That means all these URLs work with https://
as the protocol.-
or a dot .
separating s3-website
and <region>
. To see which one is right for your region, you have to check the list of Amazon S3 website endpoints.s3://<bucket>/<key>
. Other clients and SDKs probably use the regional REST endpoint with the bucket name either in the hostname or pathname.formatS3Url
, parseS3Url
, and isS3Url
.