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 Respuesta
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 hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas