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 Antwort
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
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen