Class Route53RegionProvider

java.lang.Object
software.amazon.msk.auth.iam.internals.region.Route53RegionProvider
All Implemented Interfaces:
software.amazon.awssdk.regions.providers.AwsRegionProvider, ConfigurableRegionProvider

public class Route53RegionProvider extends Object implements ConfigurableRegionProvider
A ConfigurableRegionProvider that resolves the AWS region by performing a DNS TXT record lookup via Route 53, with time-based caching.

Configuration parameters (passed via constructor map):

  • host — optional fully-qualified hostname to query for the TXT record. When provided, this value is used directly as the DNS lookup name.
  • refresh.seconds — how often, in seconds, the cached region value is refreshed via a new DNS lookup. Defaults to 60 (1 minute). Set to 0 to disable caching and resolve DNS on every call. Uses lazy evaluation: the cache is only refreshed when an authentication request needs to be signed, which typically happens during initial authentication with MSK and subsequent re-authentication to refresh session tokens. Caching reduces the number of Route 53 DNS calls, which is especially beneficial when authentication is retried repeatedly due to failures.

When no host is configured, the getRegion(String) method constructs the lookup name by prefixing the supplied host with "region." (e.g. "region.broker.example.com").

The TXT record value is expected to contain a valid AWS region id (e.g. "us-east-1").

  • Constructor Details

    • Route53RegionProvider

      public Route53RegionProvider(Map<String,String> config)
  • Method Details

    • getRegion

      public software.amazon.awssdk.regions.Region getRegion()
      Specified by:
      getRegion in interface software.amazon.awssdk.regions.providers.AwsRegionProvider
    • getRegion

      public software.amazon.awssdk.regions.Region getRegion(String host)
      Description copied from interface: ConfigurableRegionProvider
      Resolve the region using a provided host as context.
      Specified by:
      getRegion in interface ConfigurableRegionProvider
      Parameters:
      host - the host to use for region resolution
      Returns:
      the resolved AWS Region