Add support for environment token provider for services whose SigV4 signing...
Add support for environment token provider for services whose SigV4 signing names are `bedrock` (#4241) ## Motivation and Context Adds support for environment token provider for AWS services whose SigV4 service signing name matches `bedrock`. Setting this environment variable, `AWS_BEARER_TOKEN_BEDROCK`, allows SDKs to prefer the `httpBearerAuth` auth scheme and to retrieve a `Token` value from the said environment. ## Description Customers would use the environment variable in question like so: ``` // export AWS_BEARER_TOKEN_BEDROCK=my-token let sdk_config = aws_config::defaults(BehaviorVersion::latest()).load().await; let bedrock_client = aws_sdk_bedrock::Client::new(&sdk_config); // call an operation on `bedrock_client`... ``` Under the hood, this is equivalent roughly to ``` let sdk_config = aws_config::defaults(BehaviorVersion::latest()).load().await; let bedrock_config = aws_sdk_bedrock::config::Builder::from(sdk_config) .auth_scheme_preference([HTTP_BEARER_AUTH_SCHEME_ID]) .token_provider(Token::new("my-token", None)) .build(); let bedrock_client = aws_sdk_bedrock::Client::from_conf(bedrock_config); // call an operation on `bedrock_client`... ``` This behind-the-scenes convenience is implemented in `impl From<&SdkConfig> for Builder`, similar to how a service-specific environment is implemented for the [endpoint URL](https://docs.aws.amazon.com/sdkref/latest/guide/feature-ss-endpoints.html#ss-endpoints-envar). However, `impl From<&SdkConfig> for Builder` implies that customers need to create a service client from `SdkConfig` (typically through [ConfigLoader::load](https://docs.rs/aws-config/latest/aws_config/struct.ConfigLoader.html#method.load)) in order to take advantage of the environment variable. If customers create the service client directly from the service config builder, the environment variable will not be applied, i.e. ``` // export AWS_BEARER_TOKEN_BEDROCK=my-token let bedrock_config = aws_sdk_bedrock::Config::builder() // other configurations .build(); let bedrock_client = aws_sdk_bedrock::Client::from_conf(bedrock_config); // `bedrock_client` neither prefers HTTP_BEARER_AUTH_SCHEME_ID nor sets a Token with my-token. ``` ## Testing - Added integration tests for `bedrockruntime` (whose model is already checked in to `aws/sdk/aws-models`) ## Checklist - [x] For changes to the AWS SDK, generated SDK code, or SDK runtime crates, I have created a changelog entry Markdown file in the `.changelog` directory, specifying "aws-sdk-rust" in the `applies_to` key. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
Loading
Please sign in to comment