deleteKey

abstract suspend fun deleteKey(keyId: KeyId): DeleteKeyResult

Deletes a key from the key management service.

Returns a DeleteKeyResult for type-safe error handling. The operation is idempotent - deleting a non-existent key is considered success.

Example Usage:

when (val result = kms.deleteKey(keyId)) {
is DeleteKeyResult.Deleted -> {
// Key was deleted
println("Key deleted")
}
is DeleteKeyResult.NotFound -> {
// Key didn't exist (idempotent success)
println("Key not found (already deleted)")
}
is DeleteKeyResult.Failure.Error -> {
// Unexpected error
println("Error: ${result.reason}")
}
}

Return

Result indicating deletion status

Parameters

keyId

Type-safe key identifier