https://www.boundaryml.com logo
🟡 AWS Bedrock config SDK credentials error
# questions
j
Hitting a strange bug trying to get AWS Bedrock config working via Client Registry - Wondering if anyone can shed some light > BAML version 0.204.0
Copy code
options = {'model': 'us.meta.llama3-3-70b-instruct-v1:0', 'profile': 'my-bedrock-user', 'region': 'us-east-1'}

cr.add_llm_client(
    name="LLMClient", # already defined - should override
    provider="aws-bedrock",
    options=options,
    retry_policy="LLMRetry",
)

cr.set_primary("LLMClient")

return cr
My aws profile has proper access but BAML is getting a AWS SDK error saying no credntials given.. I call it via this
Copy code
...
stream = b.stream.MyQuery(
    user_input=user_input,
    baml_options={"client_registry": client_registry},
)
response = await stream.get_final_response()

...
except BamlClientError as e:
Copy code
ERROR: Client Error occurred: Something went wrong with the LLM client LLMClient: DispatchFailure(
    DispatchFailure {
        source: ConnectorError {
            kind: Other(
                None,
            ),
            source: CredentialsNotLoaded(
                CredentialsNotLoaded {
                    source: Some(
                        "no providers in chain provided credentials",
                    ),
                },
            ),
            connection: Unknown,
        },
    },
)
When i set optoins to this it works -- so maybe something with how profile is supported internally?
Copy code
{'model': 'us.meta.llama3-3-70b-instruct-v1:0', 'access_key_id': 'AKIAV...', 'secret_access_key': 'aerer...', 'region': 'us-east-1'}
b
I’m not totally sure if name overriding works the way you’re thinking it does (I’d actually have to double check that)
But… I know we have people using bedrock with AWS_PROFILE who aren’t running into this, and I agree that I don’t see anything unusual in your code
Could you try leaving
profile
unset, and just setting the AWS_PROFILE envvar?
“my-bedrock-user” also should not be the name/id of the aws user, but the name of your AWS_PROFILE in ~/.aws/config
j
Let me give that a try --- Yeah i was just going off the note in the docs https://docs.boundaryml.com/guide/baml-advanced/llm-client-registry#add_llm_client--addllmclient In clients.baml
Copy code
retry_policy LLMRetry {
  max_retries 3
  strategy {
    type exponential_backoff
    delay_ms 200
    multiplier 1.5
    max_delay_ms 10000
  }
}

client<llm> LLMClient {
  provider "openai-generic"
  retry_policy LLMRetry
  options {
    base_url env.CUSTOM_BASE_URL
    api_key env.CUSTOM_API_KEY
    model env.CUSTOM_MODEL
  }
}
> So thought here is override would reuse things but replace
provider
and
options
key with what is set through client register? > > I could try a new name as well example of ~/.aws/credentials
Copy code
[my-bedrock-user]
aws_access_key_id = AKIA...
aws_secret_access_key = aerer...
Seems to be the same issue if i exclude
profile
from the config options was set to
Copy code
{'model': 'us.meta.llama3-3-70b-instruct-v1:0', 'region': 'us-east-1'}
and ENV's
Copy code
AWS_PROFILE=my-bedrock-user
AWS_REGION=us-east-1
But still get the same DispatchFailure from sdk side
b
Hmm…
j
Now if i manually do this in the playground view and override the clients.baml to mimic what the client registry is doing... it works
Copy code
client<llm> LLMClient {
  provider "aws-bedrock"
  retry_policy LLMRetry
  options {
    region env.AWS_REGION
    model_id env.BEDROCK_MODEL_ID
    profile env.AWS_PROFILE
  }
}
Same profile, region, model in the options - Goes through So maybe points to client registry acting funny here
Could it be because im defining a client in the query function?
Copy code
function MyQuery(user_input: string) -> MyQueryResponse {
  client LLMClient
  prompt #"
    {{ SystemPrompt() }}

    The following is the user-entered input: {{ user_input }}
  "#
}
b
No, that’s standard
I’m staring at our integ tests and am not sure what’s missing
j
** i guess i answered that myself anyways.. It works with the current client registry process if i use ACCESS_ID/ACCESS_SECRET -- just not with the profile param variation
I have a working theory.. Im running inside a devcontainer -- so when i pass ID/SECRET .. no external lookup is needed by the system But if you use
profile
the AWS SDK will go and look for
$HOME/.aws/credentials
.. which in this dev container is not setup > So this is probably a big false alarm.. the container doesn't ahve
aws configure --profile my-bedrock-user
.. so the error message here makes alot more sense Let me go confirm this
b
Ahhh
yes that will absolutely do it
I… have no idea if we can add anything to the toolchain to warn you about this
j
100% that was the issue - just confirmed Mounted the host OS into the container so the file/config is there for the SDK to look up
Copy code
volumes:
  - ~/.aws:/root/.aws
--- I guess if you wanted to add some validation.. if the
profile
param is used but a CredentialsNotLoaded error is returned by AWS then you can double check this situation
$HOME/.aws/{config,credential}
should exist .. and if it does then the user has a bad profile name, or a profile doesnt exist with the name provided yet (run
aws configure --profile <name>
to continue) .. or if the user has
$AWS_SHARED_CREDENTIALS_FILE
env configured you should look there instead --- Thanks for the help on this - Good ol friday debugging
b
Ooh, that’s an interesting one- we could attach the expanded path for ~/.aws
that would definitely signal on it
glad that you’re unblocked!
j
TY!! Just buttoning up some final pieces for our project and multi provider support has been the hardest part (validating the ENVs, controls, and making sure we give good feedback on missing ENVs, etc) Really sweet use case i'll share more about soon
Well actually its public now so i can share: https://docs.keeper.io/en/keeperpam/privileged-access-manager/keeperai > Need to update the docs a bit for some changes to the provider side Remote session threat detection of user behavior - under the hood had to be super agnostic, but still return structured output for downstream use. BAML saved the day and now we use it everywhere in our workflow
b
Do post in #1280993403168886896 when you’re ready to announce announce!