Unverified Commit 8ba894b6 authored by Alberto Rosado's avatar Alberto Rosado Committed by GitHub
Browse files

Allow user to set 'policy' and 'policy_arns' in AssumeRoleProvider bu… (#1892)

parent 11e9a5f2
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -79,3 +79,9 @@ message = "Fix cargo audit issue on criterion."
references = ["smithy-rs#1923"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "ysaito1001"

[[aws-sdk-rust]]
message = "Ability to add an inline policy or a list of policy ARNs to the `AssumeRoleProvider` builder."
references = ["aws-sdk-rust#641", "smithy-rs#1892"]
meta = { "breaking" = false, "tada" = true, "bug" = false }
author = "albe-rosado"
+1 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
# require manual version bumping every time an automated version bump
# to the exposed SDK crates happens.
allowed_external_types = [
   "aws_sdk_sts::model::PolicyDescriptorType",
   "aws_smithy_async::rt::sleep::AsyncSleep",
   "aws_smithy_client::bounds::SmithyConnector",
   "aws_smithy_client::erase::DynConnector",
+27 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@

use aws_sdk_sts::error::AssumeRoleErrorKind;
use aws_sdk_sts::middleware::DefaultMiddleware;
use aws_sdk_sts::model::PolicyDescriptorType;
use aws_sdk_sts::operation::AssumeRole;
use aws_smithy_client::erase::DynConnector;
use aws_smithy_http::result::SdkError;
@@ -76,6 +77,8 @@ pub struct AssumeRoleProviderBuilder {
    region: Option<Region>,
    conf: Option<ProviderConfig>,
    session_length: Option<Duration>,
    policy: Option<String>,
    policy_arns: Option<Vec<PolicyDescriptorType>>,
}

impl AssumeRoleProviderBuilder {
@@ -94,6 +97,8 @@ impl AssumeRoleProviderBuilder {
            session_length: None,
            region: None,
            conf: None,
            policy: None,
            policy_arns: None,
        }
    }

@@ -118,6 +123,26 @@ impl AssumeRoleProviderBuilder {
        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](aws_sdk_sts::input::assume_role_input::Builder::policy_arns)
    pub fn policy(mut self, policy: impl Into<String>) -> Self {
        self.policy = Some(policy.into());
        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](aws_sdk_sts::input::assume_role_input::Builder::policy_arns)
    pub fn policy_arns(mut self, policy_arns: Vec<PolicyDescriptorType>) -> Self {
        self.policy_arns = Some(policy_arns);
        self
    }

    /// Set the expiration time of the role session.
    ///
    /// When unset, this value defaults to 1 hour.
@@ -188,6 +213,8 @@ impl AssumeRoleProviderBuilder {
            .set_role_arn(Some(self.role_arn))
            .set_external_id(self.external_id)
            .set_role_session_name(Some(session_name))
            .set_policy(self.policy)
            .set_policy_arns(self.policy_arns)
            .set_duration_seconds(self.session_length.map(|dur| dur.as_secs() as i32))
            .build()
            .expect("operation is valid");