Struct aws_config::sts::AssumeRoleProviderBuilder
source · pub struct AssumeRoleProviderBuilder { /* private fields */ }
Expand description
A builder for AssumeRoleProvider
.
Construct one through AssumeRoleProvider::builder
.
Implementations§
source§impl AssumeRoleProviderBuilder
impl AssumeRoleProviderBuilder
sourcepub fn new(role: impl Into<String>) -> Self
pub fn new(role: impl Into<String>) -> Self
Start a new assume role builder for the given role.
The role
argument should take the form an Amazon Resource Name (ARN) like
arn:aws:iam::123456789012:role/example
sourcepub fn external_id(self, id: impl Into<String>) -> Self
pub fn external_id(self, id: impl Into<String>) -> Self
Set a unique identifier that might be required when you assume a role in another account.
If the administrator of the account to which the role belongs provided you with an external ID, then provide that value in this parameter. The value can be any string, such as a passphrase or account number.
sourcepub fn session_name(self, name: impl Into<String>) -> Self
pub fn session_name(self, name: impl Into<String>) -> Self
Set an identifier for the assumed role session.
Use the role session name to uniquely identify a session when the same role is assumed by different principals or for different reasons. In cross-account scenarios, the role session name is visible to, and can be logged by the account that owns the role. The role session name is also used in the ARN of the assumed role principal.
sourcepub fn policy(self, policy: impl Into<String>) -> Self
pub fn policy(self, policy: impl Into<String>) -> Self
Set an IAM policy in JSON format that you want to use as an inline session policy.
This parameter is optional For more information, see policy
sourcepub fn policy_arns(self, policy_arns: Vec<String>) -> Self
pub fn policy_arns(self, policy_arns: Vec<String>) -> Self
Set the Amazon Resource Names (ARNs) of the IAM managed policies that you want to use as managed session policies.
This parameter is optional. For more information, see policy_arns
sourcepub fn session_length(self, length: Duration) -> Self
pub fn session_length(self, length: Duration) -> Self
Set the expiration time of the role session.
When unset, this value defaults to 1 hour.
The value specified can range from 900 seconds (15 minutes) up to the maximum session duration set for the role. The maximum session duration setting can have a value from 1 hour to 12 hours. If you specify a value higher than this setting or the administrator setting (whichever is lower), you will be unable to assume the role. For example, if you specify a session duration of 12 hours, but your administrator set the maximum session duration to 6 hours, you cannot assume the role.
For more information, see duration_seconds
sourcepub fn region(self, region: Region) -> Self
pub fn region(self, region: Region) -> Self
Set the region to assume the role in.
This dictates which STS endpoint the AssumeRole action is invoked on. This will override
a region set from .configure(...)
sourcepub fn configure(self, conf: &SdkConfig) -> Self
pub fn configure(self, conf: &SdkConfig) -> Self
Sets the configuration used for this provider
This enables overriding the connection used to communicate with STS in addition to other internal fields like the time source and sleep implementation used for caching.
If this field is not provided, configuration from [aws_config::load_from_env().await
] is used.
§Examples
use aws_types::region::Region;
use aws_config::sts::AssumeRoleProvider;
let config = aws_config::from_env().region(Region::from_static("us-west-2")).load().await;
let assume_role_provider = AssumeRoleProvider::builder("arn:aws:iam::123456789012:role/example")
.configure(&config)
.build();
}
sourcepub async fn build(self) -> AssumeRoleProvider
pub async fn build(self) -> AssumeRoleProvider
Build a credentials provider for this role.
Base credentials will be used from the SdkConfig
set via Self::configure
or loaded
from aws_config::from_env
if configure
was never called.
sourcepub async fn build_from_provider(
self,
provider: impl ProvideCredentials + 'static
) -> AssumeRoleProvider
pub async fn build_from_provider( self, provider: impl ProvideCredentials + 'static ) -> AssumeRoleProvider
Build a credentials provider for this role authorized by the given provider
.