-
Notifications
You must be signed in to change notification settings - Fork 634
Closed
Labels
feature-requestNew feature or enhancement. May require GitHub community feedback.New feature or enhancement. May require GitHub community feedback.
Description
Describe the feature
- boto3 seems to support this https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys-use.html
- Running https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javascriptv3/example_code/bedrock-runtime/hello.js does not detect and use the
AWS_BEARER_TOKEN_BEDROCK
env var and instead complains about not being able to find any credentials[0]
[0]
"type": "CredentialsProviderError",
"message": "Could not load credentials from any providers",
As a workaround creating a custom client seems to work. (I'm not sure how correct / resilient the below code is)
// Create a custom BedrockRuntimeClient with Bearer token authentication
const customClient = new BedrockRuntimeClient({
region: config.region,
// Provide dummy credentials to bypass the credential provider chain
// since we're using Bearer token authentication via the Authorization header
credentials: {
accessKeyId: "dummy",
secretAccessKey: "dummy",
},
requestHandler: {
requestTimeout: 30000,
httpsAgent: undefined,
handle: (request: any, context: any) => {
// Add Authorization header with Bearer token
request.headers = request.headers || {};
request.headers["Authorization"] = `Bearer ${config.awsBearerToken}`;
// Use the default request handler
const { NodeHttpHandler } = require("@smithy/node-http-handler");
const handler = new NodeHttpHandler();
return handler.handle(request, context);
},
},
});
Use Case
Sometimes hard to set up full IAM auth on dev machines and the env var key seems useful to simplify some flows. (but of course they come w/ a lot of warnings, not super secure etc.).
Proposed Solution
Recognise and use the AWS_BEARER_TOKEN_BEDROCK
in the credentials lookup chain.
Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
SDK version used
3.844.0
Environment details (OS name and version, etc.)
darwin/npm
Metadata
Metadata
Assignees
Labels
feature-requestNew feature or enhancement. May require GitHub community feedback.New feature or enhancement. May require GitHub community feedback.