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 Resposta
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
respondido há 2 anos

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas