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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use ;
use Metadata;
use crate;
/// The name that identifies the interceptor in the configuration of a client.
const NAME: &str = "bedrock_agentcore::identity::WatPropagation";
/// Forwards the workload access token of the current invocation on the `Invoke*`
/// operations of an AgentCore client.
///
/// The client of [`IdentityClient::data_plane`](super::IdentityClient::data_plane)
/// already has it. Add it yourself to a client that you build separately:
///
/// ```no_run
/// # async fn example() {
/// use aws_sdk_bedrockagentcore::{Client, config::Builder};
/// use bedrock_agentcore::identity::WatPropagation;
///
/// let aws = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
/// let client = Client::from_conf(Builder::from(&aws).interceptor(WatPropagation::new()).build());
/// # }
/// ```
///
/// # What it does
///
/// Before signing each attempt of an `Invoke*` operation, this interceptor sets the
/// `X-Amz-Bedrock-AgentCore-Identity-WAT` header to the workload access token from
/// the current [request context](crate::context), replacing any value set earlier.
/// To override the token for one call, set that header in `.customize().mutate_request(...)`
/// on the operation. This customization runs after the interceptor and before signing,
/// so the SDK signs the override for that call. Subsequent calls still use the context token.
///
/// In version 1.87.0 of the generated client these operations are
/// `InvokeAgentRuntime`, `InvokeAgentRuntimeCommand`, `InvokeBrowser`,
/// `InvokeCodeInterpreter`, `InvokeHarness` and `InvokeWebSearch`. An operation with
/// that prefix in a later version is included.
///
/// Other operations are sent as they are. So is an `Invoke*` operation outside a
/// request context, or in a context without a nonempty token: a task started with
/// `tokio::spawn` needs [`context::scope`](crate::context::scope).
///
/// A token that is not a valid header value fails the operation before it is sent.
/// The error does not contain the token.
///
/// # Logging
///
/// This crate does not log the token, and the AWS SDK does not log it at the `DEBUG`
/// level and above. At `TRACE`, the SDK prints each request with all of its headers
/// when it signs and when it sends it (the `aws_sigv4` and `aws_smithy_runtime`
/// targets), and that output contains the token. Keep these targets above `TRACE`
/// where logs must not hold it.
;