Resource Manager tags let you organize your AlloyDB for PostgreSQL clusters and backups,
conditionally control Identity and Access Management (IAM) access, and track usage in
Cloud Billing exports. You can attach, detach, and list tags on
AlloyDB resources by using the Google Cloud CLI. Tags attached to
a cluster resource are automatically inherited by child resources, such as
instances, and can't be overridden on those child resources.

> [!NOTE]
> **Note:** Tags are distinct from labels. Tags are managed using Resource Manager, whereas labels can be attached and managed directly on AlloyDB clusters using the Google Cloud console, the Google Cloud CLI, or the AlloyDB API. For more information about how tags work, see [Organize resources using tags](https://docs.cloud.google.com/alloydb/docs/tags.md.txt) and [Tag inheritance](https://docs.cloud.google.com/resource-manager/docs/tags/tags-overview.md.txt#inheritance).

## Before you begin


To get the permissions that
you need to view and set tags on AlloyDB resources,

ask your administrator to grant you the
following IAM roles on your project:

- Cloud AlloyDB Admin (`roles/alloydb.admin`): assign to set and view tags
- Cloud AlloyDB Viewer (`roles/alloydb.viewer`): assign to view tags


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


You might also be able to get
the required permissions through [custom
roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles) or other [predefined
roles](https://docs.cloud.google.com/iam/docs/roles-overview#predefined).

## Work with tags

After you've [created and defined](https://docs.cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing.md.txt#creating)
a tag using Resource Manager, you can start using tags with AlloyDB
cluster and backup resources. For more information about the Google Cloud CLI
commands to use tag bindings, see
[gcloud resource-manager tags bindings](https://docs.cloud.google.com/sdk/gcloud/reference/resource-manager/tags/bindings).

For all of the commands on this page, replace the following:

- `PARENT_PATH`: The complete path to the backup or cluster resource---for example, `//alloydb.googleapis.com/projects/my-project/locations/us-central1/backups/my-backup`.
- `TAG_VALUE`: The tag value that you want to attach to your resource---for example, the tag value set as `815471563813/environment/development` includes the following components:

  - `815471563813` is the organization ID or your project ID.

  - `environment` is the tag key.

  - `development` is the tag value.

- `LOCATION`: The region where your cluster or backup is placed---for example, `us-central1`.

### Attach tags to AlloyDB resources

```
gcloud resource-manager tags bindings create \
--parent=PARENT_PATH \
--tag-value=TAG_VALUE \
--location=LOCATION
```

### Detach tags from AlloyDB resources

```
gcloud resource-manager tags bindings delete \
--parent=PARENT_PATH \
--tag-value=TAG_VALUE \
--location=LOCATION
```

### List tags on AlloyDB resources

```
gcloud resource-manager tags bindings list \
--parent=PARENT_PATH \
--location=LOCATION
```

## What's next

- [Learn more about attaching tags to resources](https://docs.cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing.md.txt#attaching).
- [Export Cloud Billing data to BigQuery with resource-level tags](https://docs.cloud.google.com/alloydb/docs/tags.md.txt#billing-bq-export)