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 réponse
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
répondu il y a 2 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions