pub struct WorkloadIdentityCredentials { /* private fields */ }Expand description
A credentials provider for the AWS calls of an agent on AgentCore Runtime.
AgentCore Runtime can send an encrypted workload identity context with an
invocation. This provider exchanges it, with the GetIAMWorkloadIdentityCredentials
operation, for credentials of the execution role that carry the workload identity of
the agent. AWS clients that use this provider then call other services with those
credentials.
// `config` is the configuration of the agent, for example from `aws_config::load_defaults`.
let config = WorkloadIdentityCredentials::configure(&config);
// Build every AWS client of the agent from the returned configuration.§Which credentials a call gets
- Before any invocation carried a context, the credentials of the configuration that the provider was created from. On AgentCore Runtime these are the execution role credentials.
- After that, the credentials for the context of the session of the call. A session keeps its latest context, so an invocation without one uses the context of an earlier invocation of the same session. The credentials are requested on the first AWS call of the session, kept for it, and renewed before they expire. The context, the credentials and the refresh token of one session are never used for another.
- A call in a session that sent no context fails, when another session sent one.
- When the exchange fails, the call fails. The provider does not go back to the execution role credentials, because the call would then run without the workload identity.
- The exception is a service that does not support the operation. The provider then returns the execution role credentials and tries the exchange again later.
§The request context
The provider reads the session and the context from the ambient
request context of the AWS call. A task started with
tokio::spawn does not inherit it: wrap its future in
context::scope. A call outside a request context uses
the session of the latest call that had a context.
§The identity cache
An AWS client keeps the credentials of its provider until they expire. A client
that resolved the execution role credentials at startup would keep them after the
first invocation. configure turns that cache off, and the
provider keeps the credentials itself. Do the same when you set the provider on a
configuration yourself.
§Other processes
The provider covers the AWS SDK for Rust clients of this process. A child process, such as the AWS CLI, uses the execution role credentials.
Implementations§
Trait Implementations§
Source§impl Clone for WorkloadIdentityCredentials
impl Clone for WorkloadIdentityCredentials
Source§impl Debug for WorkloadIdentityCredentials
impl Debug for WorkloadIdentityCredentials
Source§impl ProvideCredentials for WorkloadIdentityCredentials
impl ProvideCredentials for WorkloadIdentityCredentials
Source§fn provide_credentials<'a>(&'a self) -> ProvideCredentials<'a> ⓘwhere
Self: 'a,
fn provide_credentials<'a>(&'a self) -> ProvideCredentials<'a> ⓘwhere
Self: 'a,
Source§fn fallback_on_interrupt(&self) -> Option<Credentials>
fn fallback_on_interrupt(&self) -> Option<Credentials>
Auto Trait Implementations§
impl !RefUnwindSafe for WorkloadIdentityCredentials
impl !UnwindSafe for WorkloadIdentityCredentials
impl Forget for WorkloadIdentityCredentials
impl Freeze for WorkloadIdentityCredentials
impl Move for WorkloadIdentityCredentials
impl Send for WorkloadIdentityCredentials
impl Sync for WorkloadIdentityCredentials
impl Unpin for WorkloadIdentityCredentials
impl UnsafeUnpin for WorkloadIdentityCredentials
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more