Reputation: 245
When I see the enum Regions
(amazonaws/regions/Regions.class) then I found the DEFAULT_REGION = US_WEST_2
.
Where as, On URL https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-credentials.html I found that If you don't select a region, then us-east-1 will be used by default.
When I create AmazonS3 client using new AmazonS3Client()
, it gives me us-east-1
as default region.
So, my ask is: 1.) Are these default Regions are different for different services? For now, I'm just interested in AmazonS3Client/AmazonS3ClientBuilder.
2.) Is there any significance of these? Interested in us-east-1
more..?
Upvotes: 1
Views: 8519
Reputation: 179364
There is a great deal of significance in these.
For most services, the AWS regions are all independent.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html
Services in a given region are isolated from the same service in a different region, for operational resiliency. If you create a bucket or an SQS queue or an SNS topic or a Lambda function in a far-away region, the laws of physics will impair your performance -- on a global scale, the speed of light becomes tediously slow to an extent that many people seem to underestimate. If your bucket, queue, topic, etc., is in (e.g.) us-west-2, you cannot access it via the eu-west-2 endpoint. You can access it from inside the eu-west-2 region, but your requests and their responses must traverse the ocean.
Use a region near your users and yourself. Don't just take the defaults. They are only there for historical reasons and hindsight suggests they were probably not a good idea. You may find that the default region is coincidentally your ideal choice of region, in which case use that region explicitly.
The us-east-1 region is the original, oldest, and largest region. Customers who do not actively select a region have been subtly encouraged to use us-west-2 through some of the default settings for quite some time, presumably because there is more surplus capacity there, overall (but this is speculation). The us-east-1 default may still be present in some cases, but the trend seems to be toward removing defaults and requiring a selection, which is probably how it should always have been.
Upvotes: 3
Reputation: 74
The default constructors have fixed endpoints, which (at least for the services I've used) are in us-east-1
. You can change to a different region by calling the setRegion()
or setEndpoint()
method.
However, the default constructors have been deprecated since version 1.11.11. You should now use a client builder (such as AmazonS3ClientBuilder), which will look for a configured region. Unless you have a good reason to do otherwise, call AmazonS3ClientBuilder.defaultClient()
.
Upvotes: 3