Skip to content

Support AWS_BEARER_TOKEN_BEDROCK env var for bedrock auth #7204

@foot

Description

@foot

Describe the feature

[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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions