The purpose of enableRegionalUsEast1Endpoint
method associated with AmazonS3ClientBuilder
in aws S3 SDK is to (see here):
"Enable resolving region us-east-1 as a regional endpoint instead of defaulting to the global endpoint"
But I do not see any similar methods that can enable resolving to any other regional endpoint, apart from us-east-1
.
Question: What is the way to enable regional endpoint with AWS Java SDK, for regions other than us-east-1
?
Context: My end goal is to be able to generate presigned URLs with regional domain e.g. https://<BUCKET_NAME>.s3.us-west-2.amazonaws.com/<KEY>...
.
CodePudding user response:
Each AWS client can be configured to use a specific endpoint within a region by calling the withEndpointConfiguration method when creating the client.
For example, to configure the Amazon S3 client to use the Europe (Ireland) Region, use the following code.
AmazonS3 s3 = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(new EndpointConfiguration(
"https://s3.eu-west-1.amazonaws.com",
"eu-west-1"))
.withCredentials(CREDENTIALS_PROVIDER)
.build();