Commit de4be56
authored
Add support for environment token provider for services whose SigV4 signing names are
## 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._bedrock (#4241)1 parent 0642b3b commit de4be56
File tree
24 files changed
+4954
-936
lines changed- .changelog
- aws
- rust-runtime
- aws-config/src
- aws-credential-types/src
- aws-runtime/src
- user_agent
- test_data
- sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk
- customize
- s3
- sdk
- aws-models
- integration-tests
- bedrockruntime
- tests
- codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/auth
- rust-runtime
- aws-smithy-runtime-api
- src/client
24 files changed
+4954
-936
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
894 | 894 | | |
895 | 895 | | |
896 | 896 | | |
897 | | - | |
898 | | - | |
899 | | - | |
900 | | - | |
901 | | - | |
902 | | - | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
915 | 897 | | |
916 | 898 | | |
917 | 899 | | |
918 | 900 | | |
919 | 901 | | |
920 | 902 | | |
921 | | - | |
| 903 | + | |
922 | 904 | | |
923 | 905 | | |
924 | 906 | | |
| |||
950 | 932 | | |
951 | 933 | | |
952 | 934 | | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
953 | 959 | | |
954 | 960 | | |
955 | 961 | | |
| |||
989 | 995 | | |
990 | 996 | | |
991 | 997 | | |
| 998 | + | |
992 | 999 | | |
993 | 1000 | | |
994 | 1001 | | |
| 1002 | + | |
| 1003 | + | |
995 | 1004 | | |
996 | 1005 | | |
997 | 1006 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
165 | 168 | | |
166 | 169 | | |
167 | 170 | | |
| |||
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
| 220 | + | |
| 221 | + | |
217 | 222 | | |
218 | 223 | | |
219 | 224 | | |
| |||
248 | 253 | | |
249 | 254 | | |
250 | 255 | | |
| 256 | + | |
251 | 257 | | |
252 | 258 | | |
253 | 259 | | |
| |||
336 | 342 | | |
337 | 343 | | |
338 | 344 | | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
| 345 | + | |
397 | 346 | | |
398 | 347 | | |
399 | 348 | | |
| |||
0 commit comments