This document describes how to list the Managed Kafka ACL resources that are
defined for a specified Managed Service for Apache Kafka cluster.

## Required roles and permissions


To get the permission that
you need to list Managed Kafka ACLs,

ask your administrator to grant you the
[Managed Kafka ACL Viewer](https://docs.cloud.google.com/iam/docs/roles-permissions/managedkafka.md.txt#managedkafka.aclViewer) (`roles/managedkafka.aclViewer`) IAM role on your project.


For more information about granting roles, see [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).


This predefined role contains the
`managedkafka.acls.list`
permission,
which is required to
list Managed Kafka ACLs.


You might also be able to get
this permission
with [custom roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles.md.txt) or
other [predefined roles](https://docs.cloud.google.com/iam/docs/roles-overview.md.txt#predefined).

## List ACLs

### Console

1. In the Google Cloud console, go to the **Clusters** page.


   [Go to Clusters](https://console.cloud.google.com/managedkafka/clusters)

   <br />

2. Click the name of the cluster.

3. Click the **Access control** tab.

4. Under **ACL entries**, the ACL entries for this cluster are listed.

### gcloud

Run the
[`gcloud managed-kafka acls list`](https://docs.cloud.google.com/sdk/gcloud/reference/managed-kafka/acls/list)
command:

```bash
gcloud managed-kafka acls list CLUSTER_ID \
  --location=LOCATION
```

Replace the following:

- `CLUSTER_ID` The ID of your Kafka cluster.
- `LOCATION`: The region of your Kafka cluster.

## Sample command

Run the following command to view the details of the ACL associated with a
cluster called `kafka-cluster`

```bash
gcloud managed-kafka acls list kafka-cluster \
  --location=us central1 \
```

The output is similar to the following:

```
---
aclEntries:
- host: '*'
  operation: ALL
  permissionType: ALLOW
  principal: User:admin@project.iam.gserviceaccount.com
etag: W/da909178
name: projects/gmk-consumer-smjo/locations/us-central1/clusters/default-cluster/acls/allTopics
patternType: LITERAL
resourceName: '*'
resourceType: TOPIC
---
aclEntries:
- host: '*'
  operation: ALL
  permissionType: ALLOW
  principal: User:admin@project.iam.gserviceaccount.com
etag: W/da909178
name: projects/test-project/locations/us-central1/clusters/default-cluster/acls/cluster
patternType: LITERAL
resourceName: kafka-cluster
resourceType: CLUSTER
```

The output includes the following information for each Managed Kafka ACL resource:

- `aclEntries`: a list of access control entries for this ACL resource. Each
  entry defines a permission rule:

  - `host`: the host from which the principal can access the resource. `'*'` indicates any host.
  - `operation`: the Kafka operation type granted or denied. Examples---`ALL`, `READ`, `WRITE`.
  - `permissionType`: whether the operation is `ALLOW` or `DENY`.
  - `principal`: the user or service account to which the ACL entry applies. The format is typically `User:{google_service_account_email}` or the wildcard `User:*`.
- `etag`: used for concurrency control during updates.

- `name`: the unique identifier for the Managed Kafka ACL resource, including
  the project, location, cluster, and ACL ID.

- `patternType`: the type of resource pattern defined by the ACL ID (`LITERAL`
  for a specific resource, `PREFIXED` for resources with a common prefix).

- `resourceName`: the name of the Kafka resource to which the ACL applies.
  This can be a specific name like a topic name, a prefix, or a wildcard
  (`*`). For cluster-level ACLs, it is `kafka-cluster`.

- `resourceType`: the type of Kafka resource to which the ACL applies such as
  `TOPIC`, `CLUSTER`, `GROUP`, `TRANSACTIONAL_ID`.

## What's next

- [Create an ACL](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/kafka-acls/create-kafka-acls.md.txt)

- [View an ACL](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/kafka-acls/view-kafka-acl.md.txt)

- [Update an ACL](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/kafka-acls/update-kafka-acls.md.txt)

- [Delete an ACL](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/kafka-acls/delete-kafka-acl.md.txt)

*Apache Kafka® is a registered
trademark of The Apache Software Foundation or its affiliates in the United
States and/or other countries.*