The documentation at https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html says that there are two major forms based upon region:
bucket-name.s3-website-region.amazonaws.com
bucket-name.s3-website.region.amazonaws.com
(Note the dash versus the dot before region
.) The list at https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_website_region_endpoints seems to bear this out.
I'm using the AWS Java SDK v2. I'm creating some buckets programmatically, and other's I'm just using S3Client.getBucketWebsite()
to get the bucket web site information. But the GetBucketWebsiteResponse
doesn't seem to have anything related to this.
I'd rather not hard-code a list of regions in my code mapped to the specific style of URL they use. Is there a way I can retrieve the static web site URL for a bucket using the AWS SDK?
Note that I am aware of the separate question How do I get the AWS S3 Website Endpoint URL through the API? , but that question has to do with RESTful API endpoints, not bucket static website hosting, as the answer https://stackoverflow.com/a/39468126/421049 and its comments point out.
(Interestingly from my experiments, one region which was documented to use the form bucket-name.s3-website-region.amazonaws.com
was also accessible using the form bucket-name.s3-website.region.amazonaws.com
, so maybe AWS is trying to standardize on the dot form. Nevertheless it would be best to remove all doubt and rely on the SDK for some preferred form, unless there is some official documentation with assurance that the dot form will work for all regions going forward.)