Skip to content

delete_user async

delete_user(
    user_name: existingUserNameType,
    *,
    config_overrides: Optional[AsyncIAMClientConfig] = None,
) -> None

Deletes the specified IAM user. Unlike the Amazon Web Services Management Console, when you delete a user programmatically, you must delete the items attached to the user manually, or the deletion fails. For more information, see Deleting an IAM user. Before attempting to delete a user, remove the following items:

Parameters:

  • user_name (existingUserNameType) –

    The name of the user to delete.

    This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

Raises:

  • ConcurrentModificationException –

    The request was rejected because multiple requests to change this object were submitted simultaneously. Wait a few minutes and submit your request again.

  • DeleteConflictException –

    The request was rejected because it attempted to delete a resource that has attached subordinate entities. The error message describes these entities.

  • LimitExceededException –

    The request was rejected because it attempted to create resources beyond the current Amazon Web Services account limits. The error message describes the limit exceeded.

  • 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.

  • UnknownServiceError –

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

Examples:

To delete an IAM user The following command removes the IAM user named Bob from the current account.

>>> await client.delete_user(user_name='Bob')
Source code in docs_src/capo_iam/_services/async_iam.py
async def delete_user(
    self,
    user_name: "capo_iam.types.existing_user_name_type.existingUserNameType",
    *,
    config_overrides: Optional[AsyncIAMClientConfig] = None,
) -> None:
    """<p>Deletes the specified IAM user. Unlike the Amazon Web Services Management Console, when you delete a user programmatically, you must delete the items attached to the user manually, or the deletion fails. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_manage.html#id_users_deleting_cli">Deleting an IAM user</a>. Before attempting to delete a user, remove the following items:</p> <ul> <li> <p>Password (<a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteLoginProfile.html">DeleteLoginProfile</a>)</p> </li> <li> <p>Access keys (<a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteAccessKey.html">DeleteAccessKey</a>)</p> </li> <li> <p>Signing certificate (<a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteSigningCertificate.html">DeleteSigningCertificate</a>)</p> </li> <li> <p>SSH public key (<a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteSSHPublicKey.html">DeleteSSHPublicKey</a>)</p> </li> <li> <p>Git credentials (<a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteServiceSpecificCredential.html">DeleteServiceSpecificCredential</a>)</p> </li> <li> <p>Multi-factor authentication (MFA) device (<a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeactivateMFADevice.html">DeactivateMFADevice</a>, <a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteVirtualMFADevice.html">DeleteVirtualMFADevice</a>)</p> </li> <li> <p>Inline policies (<a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeleteUserPolicy.html">DeleteUserPolicy</a>)</p> </li> <li> <p>Attached managed policies (<a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_DetachUserPolicy.html">DetachUserPolicy</a>)</p> </li> <li> <p>Group memberships (<a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_RemoveUserFromGroup.html">RemoveUserFromGroup</a>)</p> </li> </ul>

    Args:
        user_name: <p>The name of the user to delete.</p> <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>

    Raises:
        capo_iam.errors.concurrent_modification_exception.ConcurrentModificationException: <p>The request was rejected because multiple requests to change this object were submitted simultaneously. Wait a few minutes and submit your request again.</p>
        capo_iam.errors.delete_conflict_exception.DeleteConflictException: <p>The request was rejected because it attempted to delete a resource that has attached subordinate entities. The error message describes these entities.</p>
        capo_iam.errors.limit_exceeded_exception.LimitExceededException: <p>The request was rejected because it attempted to create resources beyond the current Amazon Web Services account limits. The error message describes the limit exceeded.</p>
        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.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To delete an IAM user
        The following command removes the IAM user named Bob from the current account.

        >>> await client.delete_user(user_name='Bob')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_iam.types.delete_user_request.DeleteUserRequest]",
    ) -> AsyncOperationResponse[None]:
        import capo_iam._operations.aws_identity_management_v20100508.delete_user

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteUser")
    )
    input_: capo_iam.types.delete_user_request.DeleteUserRequest = {
        "user_name": user_name
    }

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