pub struct StsAssumeRoleSessionCredentialsProvider { /* private fields */ }
Expand description
AwsCredentials provider that calls
AssumeRole
using the provided StsClient.
To use with MFA, pass in the MFA serial number then set the MFA code.
You will need to ensure the provider has a valid code each time you
acquire a new STS token.
Implementations
sourceimpl StsAssumeRoleSessionCredentialsProvider
impl StsAssumeRoleSessionCredentialsProvider
sourcepub fn new(
sts_client: StsClient,
role_arn: String,
session_name: String,
external_id: Option<String>,
session_duration: Option<Duration>,
scope_down_policy: Option<String>,
mfa_serial: Option<String>
) -> StsAssumeRoleSessionCredentialsProvider
pub fn new(
sts_client: StsClient,
role_arn: String,
session_name: String,
external_id: Option<String>,
session_duration: Option<Duration>,
scope_down_policy: Option<String>,
mfa_serial: Option<String>
) -> StsAssumeRoleSessionCredentialsProvider
Creates a new StsAssumeRoleSessionCredentialsProvider
with the given
StsClient and session parameters.
sts_client
- StsClient to use to acquire session tokens.role_arn
- The ARN of the role to assume.session_name
- An identifier for the assumed role session. Minimum length of 2. Maximum length of 64. Pattern:[\w+=,.@-]*
external_id
-session_duration
- Duration of session tokens. Default 1 hour.scope_down_policy
- Optional inline IAM policy in JSON format to further restrict the access granted to the negotiated session.mfa_serial
- Optional MFA hardware device serial number or virtual device ARN. Useset_mfa_code
to set the MFA code.
sourcepub fn set_mfa_code<S>(&mut self, code: S) where
S: Into<String>,
pub fn set_mfa_code<S>(&mut self, code: S) where
S: Into<String>,
Set the MFA code for use when acquiring session tokens.
sourcepub fn clear_mfa_code(&mut self)
pub fn clear_mfa_code(&mut self)
Clear the MFA code.
sourcepub async fn assume_role(
&self
) -> Result<AwsCredentials, RusotoError<AssumeRoleError>>
pub async fn assume_role(
&self
) -> Result<AwsCredentials, RusotoError<AssumeRoleError>>
Calls AssumeRole
to get a session token from the STS Api.
Optionally uses MFA if the MFA serial number and code are set.
Trait Implementations
sourceimpl ProvideAwsCredentials for StsAssumeRoleSessionCredentialsProvider
impl ProvideAwsCredentials for StsAssumeRoleSessionCredentialsProvider
Auto Trait Implementations
impl !RefUnwindSafe for StsAssumeRoleSessionCredentialsProvider
impl Send for StsAssumeRoleSessionCredentialsProvider
impl Sync for StsAssumeRoleSessionCredentialsProvider
impl Unpin for StsAssumeRoleSessionCredentialsProvider
impl !UnwindSafe for StsAssumeRoleSessionCredentialsProvider
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more