Skip to content

update_role async

update_role(
    role_name: roleNameType,
    *,
    config_overrides: Optional[AsyncIAMClientConfig] = None,
    description: Optional[roleDescriptionType] = None,
    max_session_duration: Optional[roleMaxSessionDurationType] = None,
) -> UpdateRoleResponse

Updates the description or maximum session duration setting of a role.

Parameters:

  • role_name (roleNameType) –

    The name of the role that you want to modify.

  • description (Optional[roleDescriptionType], default: None ) –

    The new description that you want to apply to the specified role.

  • max_session_duration (Optional[roleMaxSessionDurationType], default: None ) –

    The maximum session duration (in seconds) that you want to set for the specified role. If you do not specify a value for this setting, the default value of one hour is applied. This setting can have a value from 1 hour to 12 hours.

    Anyone who assumes the role from the CLI or API can use the DurationSeconds API parameter or the duration-seconds CLI parameter to request a longer session. The MaxSessionDuration setting determines the maximum duration that can be requested using the DurationSeconds parameter. If users don't specify a value for the DurationSeconds parameter, their security credentials are valid for one hour by default. This applies when you use the AssumeRole* API operations or the assume-role* CLI operations but does not apply when you use those operations to create a console URL. For more information, see Using IAM roles in the IAM User Guide.

    IAM role credentials provided by Amazon EC2 instances assigned to the role are not subject to the specified maximum session duration.

Raises:

  • NoSuchEntityException –

    The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource.

  • ServiceFailureException –

    The request processing has failed because of an unknown error, exception or failure.

  • UnmodifiableEntityException –

    The request was rejected because service-linked roles are protected Amazon Web Services resources. Only the service that depends on the service-linked role can modify or delete the role on your behalf. The error message includes the name of the service that depends on this service-linked role. You must request the change through that service.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_iam/_services/async_iam.py
async def update_role(
    self,
    role_name: "capo_iam.types.role_name_type.roleNameType",
    *,
    config_overrides: Optional[AsyncIAMClientConfig] = None,
    description: Optional[
        "capo_iam.types.role_description_type.roleDescriptionType"
    ] = None,
    max_session_duration: Optional[
        "capo_iam.types.role_max_session_duration_type.roleMaxSessionDurationType"
    ] = None,
) -> "capo_iam.types.update_role_response.UpdateRoleResponse":
    """<p>Updates the description or maximum session duration setting of a role.</p>

    Args:
        role_name: <p>The name of the role that you want to modify.</p>
        description: <p>The new description that you want to apply to the specified role.</p>
        max_session_duration: <p>The maximum session duration (in seconds) that you want to set for the specified role. If you do not specify a value for this setting, the default value of one hour is applied. This setting can have a value from 1 hour to 12 hours.</p> <p>Anyone who assumes the role from the CLI or API can use the <code>DurationSeconds</code> API parameter or the <code>duration-seconds</code> CLI parameter to request a longer session. The <code>MaxSessionDuration</code> setting determines the maximum duration that can be requested using the <code>DurationSeconds</code> parameter. If users don't specify a value for the <code>DurationSeconds</code> parameter, their security credentials are valid for one hour by default. This applies when you use the <code>AssumeRole*</code> API operations or the <code>assume-role*</code> CLI operations but does not apply when you use those operations to create a console URL. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html">Using IAM roles</a> in the <i>IAM User Guide</i>.</p> <note> <p>IAM role credentials provided by Amazon EC2 instances assigned to the role are not subject to the specified maximum session duration.</p> </note>

    Raises:
        capo_iam.errors.no_such_entity_exception.NoSuchEntityException: <p>The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource.</p>
        capo_iam.errors.service_failure_exception.ServiceFailureException: <p>The request processing has failed because of an unknown error, exception or failure.</p>
        capo_iam.errors.unmodifiable_entity_exception.UnmodifiableEntityException: <p>The request was rejected because service-linked roles are protected Amazon Web Services resources. Only the service that depends on the service-linked role can modify or delete the role on your behalf. The error message includes the name of the service that depends on this service-linked role. You must request the change through that service.</p>
        capo_iam.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_iam.types.update_role_request.UpdateRoleRequest]",
    ) -> AsyncOperationResponse[
        "capo_iam.types.update_role_response.UpdateRoleResponse"
    ]:
        import capo_iam._operations.aws_identity_management_v20100508.update_role

        (
            output,
            http_response,
        ) = await capo_iam._operations.aws_identity_management_v20100508.update_role.async_update_role(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateRole")
    )
    input_: capo_iam.types.update_role_request.UpdateRoleRequest = {
        "role_name": role_name
    }
    if description is not None:
        input_["description"] = description
    if max_session_duration is not None:
        input_["max_session_duration"] = max_session_duration

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output