Class BedrockClients

java.lang.Object
ai.redouble.nucleo.providers.bedrock.BedrockClients

public final class BedrockClients extends Object
Builds the framework's configured BedrockRuntimeClient: credentials per credentialsProvider(), the region per region(), SDK retries disabled (the framework's dispatcher owns retry/backoff), and the audit interceptor registered (a no-op on calls without an LLM_REQUEST execution attribute, e.g. embeddings). Shared by every Bedrock-backed client so the auth/transport wiring exists exactly once.

Bedrock takes three things from the deployment and nothing implies any of them from the others: an access key id, a secret access key, and a region. An IAM key is account-wide and region-free, and Bedrock is regional: model access, quotas and the listing are all per region, and every call, including one on a cross-region or global inference profile, goes to one region's endpoint. The runtime invents no way of providing them. AWS's own resolution, the default credentials and region chains, reads what every AWS user already has: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION in the environment, a profile, or the role the process runs under on ECS, EC2 or EKS. A deployment that keeps its secrets elsewhere holds them in its Secrets store under SECRET_ID and REGION_ID, and a record there is used before the chain. Nothing is defaulted: a region the deployment did not choose is a wrong region. A region where AWS serves no Bedrock at all builds endpoint names DNS has never heard of, and the clients fail such a call fast as an unresolvable-endpoint configuration error; a region that serves Bedrock but not this account's models fails on the first call with the provider's own error, which says nothing about regions.

Since:
0.1 (2026-08-10)
Author:
Andrey Santrosyan
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final CredentialShape
    The pair as AWS names its two halves in the environment.
    static final String
    The id of the region every Bedrock surface calls, in the same store: the secret part carries the region name.
    static final CredentialShape
    The region as AWS names it in the environment.
    static final String
    The id of the AWS credential pair in a deployment's own secret store: user is the access key id, secret the secret access key.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Whether this deployment can call Bedrock: a region and an identity both resolve, from the store or from the AWS chains.
    static software.amazon.awssdk.auth.credentials.AwsCredentialsProvider
    The credentials every Bedrock surface signs with - the runtime client here, and the Anthropic SDK backends of nucleo-provider-bedrock-anthropic.
    static String
    How a person provides what configured() checks, for a refusal that names it: the region and the identity, each as the store describes it by the credential's shape, plus AWS's own resolution, which the runtime hands the SDK when the store holds nothing.
    static software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient
     
    refineUnknownHost(RuntimeException e, ModelSpec model, software.amazon.awssdk.regions.Region region)
    Refines an SDK failure whose cause is an unresolvable Bedrock hostname into the mistake a person can act on: the model is not served in the deployment's region, because the region is what built the hostname.
    static software.amazon.awssdk.regions.Region
    The region every Bedrock surface calls: the store's record under REGION_ID when the deployment holds one, else what the AWS default region chain resolves.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SECRET_ID

      public static final String SECRET_ID
      The id of the AWS credential pair in a deployment's own secret store: user is the access key id, secret the secret access key. A record is the pair, both halves; a half record is no record, and the chain reads what AWS's own resolution finds.
      See Also:
    • REGION_ID

      public static final String REGION_ID
      The id of the region every Bedrock surface calls, in the same store: the secret part carries the region name.
      See Also:
    • KEY_PAIR_SHAPE

      public static final CredentialShape KEY_PAIR_SHAPE
      The pair as AWS names its two halves in the environment.
    • REGION_SHAPE

      public static final CredentialShape REGION_SHAPE
      The region as AWS names it in the environment.
  • Method Details

    • region

      public static software.amazon.awssdk.regions.Region region()
      The region every Bedrock surface calls: the store's record under REGION_ID when the deployment holds one, else what the AWS default region chain resolves. The chain's own failure propagates, naming what it looked for.
    • refineUnknownHost

      public static RuntimeException refineUnknownHost(RuntimeException e, ModelSpec model, software.amazon.awssdk.regions.Region region)
      Refines an SDK failure whose cause is an unresolvable Bedrock hostname into the mistake a person can act on: the model is not served in the deployment's region, because the region is what built the hostname. Only the Bedrock clients can say this - other providers' endpoints have nothing to do with regions - so they call this around their SDK calls, and the generic classifier leaves the refined failure alone. Any other failure comes back unchanged.
    • newRuntimeClient

      public static software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient newRuntimeClient()
    • credentialsProvider

      public static software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsProvider()
      The credentials every Bedrock surface signs with - the runtime client here, and the Anthropic SDK backends of nucleo-provider-bedrock-anthropic. One decision point, so a deployment cannot end up authenticating one way for embeddings and another for chat.

      The store's key pair under SECRET_ID when the deployment holds one; otherwise the AWS default provider chain, which resolves the identity the process already has - the standard variables, a profile, or the role it runs under on ECS, EC2 or EKS. A deployment on a role therefore provisions no key anywhere. The chain is handed over as a provider rather than a fixed pair because role credentials expire and the SDK must fetch the next ones.

    • configured

      public static boolean configured()
      Whether this deployment can call Bedrock: a region and an identity both resolve, from the store or from the AWS chains. A chain's own failure IS the answer, so it is reported as false rather than propagated. No Bedrock call is made.
    • describeCredentials

      public static String describeCredentials()
      How a person provides what configured() checks, for a refusal that names it: the region and the identity, each as the store describes it by the credential's shape, plus AWS's own resolution, which the runtime hands the SDK when the store holds nothing.