aws_sdk_iam/operation/add_role_to_instance_profile/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::add_role_to_instance_profile::_add_role_to_instance_profile_output::AddRoleToInstanceProfileOutputBuilder;
3
4pub use crate::operation::add_role_to_instance_profile::_add_role_to_instance_profile_input::AddRoleToInstanceProfileInputBuilder;
5
6impl crate::operation::add_role_to_instance_profile::builders::AddRoleToInstanceProfileInputBuilder {
7    /// Sends a request with this input using the given client.
8    pub async fn send_with(
9        self,
10        client: &crate::Client,
11    ) -> ::std::result::Result<
12        crate::operation::add_role_to_instance_profile::AddRoleToInstanceProfileOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::add_role_to_instance_profile::AddRoleToInstanceProfileError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.add_role_to_instance_profile();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `AddRoleToInstanceProfile`.
24///
25/// <p>Adds the specified IAM role to the specified instance profile. An instance profile can contain only one role, and this quota cannot be increased. You can remove the existing role and then add a different role to an instance profile. You must then wait for the change to appear across all of Amazon Web Services because of <a href="https://en.wikipedia.org/wiki/Eventual_consistency">eventual consistency</a>. To force the change, you must <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DisassociateIamInstanceProfile.html">disassociate the instance profile</a> and then <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AssociateIamInstanceProfile.html">associate the instance profile</a>, or you can stop your instance and then restart it.</p><note>
26/// <p>The caller of this operation must be granted the <code>PassRole</code> permission on the IAM role by a permissions policy.</p>
27/// </note> <important>
28/// <p>When using the <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_iam-condition-keys.html#available-keys-for-iam">iam:AssociatedResourceArn</a> condition in a policy to restrict the <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_passrole.html">PassRole</a> IAM action, special considerations apply if the policy is intended to define access for the <code>AddRoleToInstanceProfile</code> action. In this case, you cannot specify a Region or instance ID in the EC2 instance ARN. The ARN value must be <code>arn:aws:ec2:*:CallerAccountId:instance/*</code>. Using any other ARN value may lead to unexpected evaluation results.</p>
29/// </important>
30/// <p>For more information about roles, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html">IAM roles</a> in the <i>IAM User Guide</i>. For more information about instance profiles, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html">Using instance profiles</a> in the <i>IAM User Guide</i>.</p>
31#[derive(::std::clone::Clone, ::std::fmt::Debug)]
32pub struct AddRoleToInstanceProfileFluentBuilder {
33    handle: ::std::sync::Arc<crate::client::Handle>,
34    inner: crate::operation::add_role_to_instance_profile::builders::AddRoleToInstanceProfileInputBuilder,
35    config_override: ::std::option::Option<crate::config::Builder>,
36}
37impl
38    crate::client::customize::internal::CustomizableSend<
39        crate::operation::add_role_to_instance_profile::AddRoleToInstanceProfileOutput,
40        crate::operation::add_role_to_instance_profile::AddRoleToInstanceProfileError,
41    > for AddRoleToInstanceProfileFluentBuilder
42{
43    fn send(
44        self,
45        config_override: crate::config::Builder,
46    ) -> crate::client::customize::internal::BoxFuture<
47        crate::client::customize::internal::SendResult<
48            crate::operation::add_role_to_instance_profile::AddRoleToInstanceProfileOutput,
49            crate::operation::add_role_to_instance_profile::AddRoleToInstanceProfileError,
50        >,
51    > {
52        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
53    }
54}
55impl AddRoleToInstanceProfileFluentBuilder {
56    /// Creates a new `AddRoleToInstanceProfileFluentBuilder`.
57    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
58        Self {
59            handle,
60            inner: ::std::default::Default::default(),
61            config_override: ::std::option::Option::None,
62        }
63    }
64    /// Access the AddRoleToInstanceProfile as a reference.
65    pub fn as_input(&self) -> &crate::operation::add_role_to_instance_profile::builders::AddRoleToInstanceProfileInputBuilder {
66        &self.inner
67    }
68    /// Sends the request and returns the response.
69    ///
70    /// If an error occurs, an `SdkError` will be returned with additional details that
71    /// can be matched against.
72    ///
73    /// By default, any retryable failures will be retried twice. Retry behavior
74    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
75    /// set when configuring the client.
76    pub async fn send(
77        self,
78    ) -> ::std::result::Result<
79        crate::operation::add_role_to_instance_profile::AddRoleToInstanceProfileOutput,
80        ::aws_smithy_runtime_api::client::result::SdkError<
81            crate::operation::add_role_to_instance_profile::AddRoleToInstanceProfileError,
82            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
83        >,
84    > {
85        let input = self
86            .inner
87            .build()
88            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
89        let runtime_plugins = crate::operation::add_role_to_instance_profile::AddRoleToInstanceProfile::operation_runtime_plugins(
90            self.handle.runtime_plugins.clone(),
91            &self.handle.conf,
92            self.config_override,
93        );
94        crate::operation::add_role_to_instance_profile::AddRoleToInstanceProfile::orchestrate(&runtime_plugins, input).await
95    }
96
97    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
98    pub fn customize(
99        self,
100    ) -> crate::client::customize::CustomizableOperation<
101        crate::operation::add_role_to_instance_profile::AddRoleToInstanceProfileOutput,
102        crate::operation::add_role_to_instance_profile::AddRoleToInstanceProfileError,
103        Self,
104    > {
105        crate::client::customize::CustomizableOperation::new(self)
106    }
107    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
108        self.set_config_override(::std::option::Option::Some(config_override.into()));
109        self
110    }
111
112    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
113        self.config_override = config_override;
114        self
115    }
116    /// <p>The name of the instance profile to update.</p>
117    /// <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-</p>
118    pub fn instance_profile_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
119        self.inner = self.inner.instance_profile_name(input.into());
120        self
121    }
122    /// <p>The name of the instance profile to update.</p>
123    /// <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-</p>
124    pub fn set_instance_profile_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
125        self.inner = self.inner.set_instance_profile_name(input);
126        self
127    }
128    /// <p>The name of the instance profile to update.</p>
129    /// <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-</p>
130    pub fn get_instance_profile_name(&self) -> &::std::option::Option<::std::string::String> {
131        self.inner.get_instance_profile_name()
132    }
133    /// <p>The name of the role to add.</p>
134    /// <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-</p>
135    pub fn role_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
136        self.inner = self.inner.role_name(input.into());
137        self
138    }
139    /// <p>The name of the role to add.</p>
140    /// <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-</p>
141    pub fn set_role_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
142        self.inner = self.inner.set_role_name(input);
143        self
144    }
145    /// <p>The name of the role to add.</p>
146    /// <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-</p>
147    pub fn get_role_name(&self) -> &::std::option::Option<::std::string::String> {
148        self.inner.get_role_name()
149    }
150}