Regions.getCurrentRegion() for AWS SDK 2.0

0

From this link: https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/migration-client-region.html Regions.getCurrentRegion() is still not supported for AWS SDK 2.0. So what is the alternative that we could do in order to get the region of our cluster.

1 個回答
2

Regions.getCurrentRegion() does not have an equivalent in v2.

You could use the DefaultAwsRegionProviderChain class that looks for the region in this order:

  1. Check the aws.region system property for the region.
  2. Check the AWS_REGION environment variable for the region.
  3. Check the {user.home}/.aws/credentials and {user.home}/.aws/config files for the region.
  4. If running in EC2, check the EC2 metadata service for the region.
var regionProvider = DefaultAwsRegionProviderChain.builder().build();
var region = regionProvider.getRegion();
profile pictureAWS
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南