Skip to content

delete_access_key async

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

Deletes the access key pair associated with the specified IAM user.

If you do not specify a user name, IAM determines the user name implicitly based on the Amazon Web Services access key ID signing the request. This operation works for access keys under the Amazon Web Services account. Consequently, you can use this operation to manage Amazon Web Services account root user credentials even if the Amazon Web Services account has no associated users.

Parameters:

  • user_name (Optional[existingUserNameType], default: None ) –

    The name of the user whose access key pair you want 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: _+=,.@-

  • access_key_id (accessKeyIdType) –

    The access key ID for the access key ID and secret access key you want to delete.

    This parameter allows (through its regex pattern) a string of characters that can consist of any upper or lowercased letter or digit.

Raises:

  • 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 access key for an IAM user The following command deletes one access key (access key ID and secret access key) assigned to the IAM user named Bob.

>>> await client.delete_access_key(user_name='Bob', access_key_id='AKIDPMS9RO4H3FEXAMPLE')
Source code in docs_src/capo_iam/_services/async_iam.py
async def delete_access_key(
    self,
    access_key_id: "capo_iam.types.access_key_id_type.accessKeyIdType",
    *,
    config_overrides: Optional[AsyncIAMClientConfig] = None,
    user_name: Optional[
        "capo_iam.types.existing_user_name_type.existingUserNameType"
    ] = None,
) -> None:
    """<p>Deletes the access key pair associated with the specified IAM user.</p> <p>If you do not specify a user name, IAM determines the user name implicitly based on the Amazon Web Services access key ID signing the request. This operation works for access keys under the Amazon Web Services account. Consequently, you can use this operation to manage Amazon Web Services account root user credentials even if the Amazon Web Services account has no associated users.</p>

    Args:
        user_name: <p>The name of the user whose access key pair you want 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>
        access_key_id: <p>The access key ID for the access key ID and secret access key you want to delete.</p> <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters that can consist of any upper or lowercased letter or digit.</p>

    Raises:
        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 access key for an IAM user
        The following command deletes one access key (access key ID and secret access key) assigned to the IAM user named Bob.

        >>> await client.delete_access_key(user_name='Bob', access_key_id='AKIDPMS9RO4H3FEXAMPLE')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_iam.types.delete_access_key_request.DeleteAccessKeyRequest]",
    ) -> AsyncOperationResponse[None]:
        import capo_iam._operations.aws_identity_management_v20100508.delete_access_key

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteAccessKey")
    )
    input_: capo_iam.types.delete_access_key_request.DeleteAccessKeyRequest = {
        "access_key_id": access_key_id
    }
    if user_name is not None:
        input_["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