

# Working with tags and labels for Amazon Keyspaces resources
<a name="tagging-keyspaces"></a>

 You can label Amazon Keyspaces (for Apache Cassandra) resources using *tags*. Tags let you categorize your resources in different ways—for example, by purpose, owner, environment, or other criteria. Tags can help you do the following: 
+  Quickly identify a resource based on the tags that you assigned to it. 
+  See AWS bills broken down by tags. 
+ Control access to Amazon Keyspaces resources based on tags. For IAM policy examples using tags, see [Authorization based on Amazon Keyspaces tags](security_iam_service-with-iam.md#security_iam_service-with-iam-tags).

 Tagging is supported by AWS services like Amazon Elastic Compute Cloud (Amazon EC2), Amazon Simple Storage Service (Amazon S3), Amazon Keyspaces, and more. Efficient tagging can provide cost insights by enabling you to create reports across services that carry a specific tag. 

 To get started with tagging, do the following: 

1.  Understand [Restrictions for using tags to label resources in Amazon Keyspaces](TaggingRestrictions.md). 

1.  Create tags by using [Tag keyspaces, tables, and streams in Amazon Keyspaces](Tagging.Operations.md). 

1.  Use [Create cost allocation reports using tags for Amazon Keyspaces](CostAllocationReports.md) to track your AWS costs per active tag. 

 Finally, it is good practice to follow optimal tagging strategies. For information, see [AWS tagging strategies](https://d0.awsstatic.com/aws-answers/AWS_Tagging_Strategies.pdf). 

# Restrictions for using tags to label resources in Amazon Keyspaces
<a name="TaggingRestrictions"></a>

 Each tag consists of a key and a value, both of which you define. The following restrictions apply: 
+  Each Amazon Keyspaces keyspace, table, or stream can have only one tag with the same key. If you try to add an existing tag (same key), the existing tag value is updated to the new value. 
+ Tags applied to a keyspace don't automatically apply to tables within that keyspace. To apply the same tag to a keyspace and all its tables, each resource must be individually tagged.
+ Tags applied to a table don't automatically apply to the stream of that table. To apply the same tags to a table and the stream during table creation, you can use the `PropagateTagsOnEnable` flag when you create the table. Using this flag, Amazon Keyspaces applies the tags of the table to the stream during stream creation. When the stream is active, changes to the table tags don't apply to the stream.
+ When you create a multi-Region keyspace or table, any tags that you define during the creation process are automatically applied to all keyspaces and tables in all Regions. When you change existing tags using `ALTER KEYSPACE` or `ALTER TABLE`, the update is only applied to the keyspace or table in the Region where you're making the change.
+ A value acts as a descriptor within a tag category (key). In Amazon Keyspaces the value cannot be empty or null.
+  Tag keys and values are case sensitive. 
+  The maximum key length is 128 Unicode characters. 
+ The maximum value length is 256 Unicode characters. 
+  The allowed characters are letters, white space, and numbers, plus the following special characters: `+ - = . _ : /` 
+  The maximum number of tags per resource is 50.
+ AWS-assigned tag names and values are automatically assigned the `aws:` prefix, which you can't assign. AWS-assigned tag names don't count toward the tag limit of 50. User-assigned tag names have the prefix `user:` in the cost allocation report. 
+  You can't backdate the application of a tag. 

# Tag keyspaces, tables, and streams in Amazon Keyspaces
<a name="Tagging.Operations"></a>

You can add, list, edit, or delete tags for keyspaces, tables, and streams using the Amazon Keyspaces console, the AWS CLI, or Cassandra Query Language (CQL). You can then activate these user-defined tags so that they appear on the AWS Billing and Cost Management console for cost allocation tracking. For more information, see [Create cost allocation reports using tags for Amazon Keyspaces](CostAllocationReports.md). 

 For bulk editing, you can also use Tag Editor on the console. For more information, see [Working with Tag Editor](https://docs.aws.amazon.com/awsconsolehelpdocs/latest/gsg/tag-editor.html) in the *AWS Resource Groups User Guide*. 

For information about tag structure, see [Restrictions for using tags to label resources in Amazon Keyspaces](TaggingRestrictions.md). 

**Topics**
+ [Add tags when creating a new keyspace](Tagging.Operations.new.keyspace.md)
+ [Add tags to a keyspace](Tagging.Operations.existing.keyspace.md)
+ [Delete tags from a keyspace](Tagging.Operations.existing.keyspace.drop.md)
+ [View the tags of a keyspace](Tagging.Operations.view.keyspace.md)
+ [Add tags when creating a new table](Tagging.Operations.new.table.md)
+ [Add tags to a table](Tagging.Operations.existing.table.md)
+ [Delete tags from a table](Tagging.Operations.existing.table.drop.md)
+ [View the tags of a table](Tagging.Operations.view.table.md)
+ [Add tags to a new stream when creating a table](Tagging.Operations.new.table.stream.md)
+ [Add tags to a new stream for an existing table](Tagging.Operations.new.stream.md)
+ [Add new tags to a stream](Tagging.Operations.existing.stream.md)
+ [Delete tags from a stream](Tagging.Operations.existing.stream.drop.md)
+ [View the tags of a stream](Tagging.Operations.view.stream.md)

# Add tags when creating a new keyspace
<a name="Tagging.Operations.new.keyspace"></a>

You can use the Amazon Keyspaces console, CQL or the AWS CLI to add tags when you create a new keyspace. 

------
#### [ Console ]

**Set a tag when creating a new keyspace using the console**

1. Sign in to the AWS Management Console, and open the Amazon Keyspaces console at [https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home).

1. In the navigation pane, choose **Keyspaces**, and then choose **Create keyspace**.

1. On the **Create keyspace** page, provide a name for the keyspace. 

1. Under **Tags** choose **Add new tag** and enter a key and a value.

1. Choose **Create keyspace**.

------
#### [ Cassandra Query Language (CQL) ]

**Set a tag when creating a new keyspace using CQL**
+ The following example creates a new keyspace with tags.

  ```
  CREATE KEYSPACE mykeyspace WITH TAGS = {'key1':'val1', 'key2':'val2'};
  ```

------
#### [ CLI ]

**Set a tag when creating a new keyspace using the AWS CLI**
+ The following statement creates a new keyspace with tags.

  ```
  aws keyspaces create-keyspace --keyspace-name 'myKeyspace' --tags 'key=key1,value=val1' 'key=key2,value=val2'
  ```

------

# Add tags to a keyspace
<a name="Tagging.Operations.existing.keyspace"></a>

The following examples show how to add tags to a keyspace in Amazon Keyspaces.

------
#### [ Console ]

**Add a tag to an existing keyspace using the console**

1. Sign in to the AWS Management Console, and open the Amazon Keyspaces console at [https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home).

1. In the navigation pane, choose **Keyspaces**.

1. Choose a keyspace from the list. Then choose the **Tags** tab where you can view the tags of the keyspace.

1. Choose **Manage tags** to add, edit, or delete tags.

1. Choose **Save changes**.

------
#### [ Cassandra Query Language (CQL) ]

**Add a tag to an existing keyspace using CQL**
+ 

  ```
  ALTER KEYSPACE mykeyspace ADD TAGS {'key1':'val1', 'key2':'val2'};
  ```

------
#### [ CLI ]

**Add a tag to an existing keyspace using the AWS CLI**
+ The following example shows how to add new tags to an existing keyspace.

  ```
  aws keyspaces tag-resource --resource-arn 'arn:aws:cassandra:us-east-1:111122223333:/keyspace/myKeyspace/' --tags 'key=key3,value=val3' 'key=key4,value=val4'
  ```

------

# Delete tags from a keyspace
<a name="Tagging.Operations.existing.keyspace.drop"></a>

------
#### [ Console ]

**Delete a tag from an existing keyspace using the console**

1. Sign in to the AWS Management Console, and open the Amazon Keyspaces console at [https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home).

1. In the navigation pane, choose **Keyspaces**.

1. Choose a keyspace from the list. Then choose the **Tags** tab where you can view the tags of the keyspace.

1. Choose **Manage tags** and delete the tags you don't need anymore.

1. Choose **Save changes**.

------
#### [ Cassandra Query Language (CQL) ]

**Delete a tag from an existing keyspace using CQL**
+ 

  ```
  ALTER KEYSPACE mykeyspace DROP TAGS {'key1':'val1', 'key2':'val2'};
  ```

------
#### [ CLI ]

**Delete a tag from an existing keyspace using the AWS CLI**
+ The following statement removes the specified tags from a keyspace.

  ```
  aws keyspaces untag-resource --resource-arn 'arn:aws:cassandra:us-east-1:111122223333:/keyspace/myKeyspace/' --tags 'key=key3,value=val3' 'key=key4,value=val4'
  ```

------

# View the tags of a keyspace
<a name="Tagging.Operations.view.keyspace"></a>

The following examples show how to read tags using the console, CQL or the AWS CLI.

------
#### [ Console ]

**View the tags of a keyspace using the Amazon Keyspaces console**

1. Sign in to the AWS Management Console, and open the Amazon Keyspaces console at [https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home).

1. In the navigation pane, choose **Keyspaces**.

1. Choose a keyspace from the list. Then choose the **Tags** tab where you can view the tags of the keyspace.

------
#### [ Cassandra Query Language (CQL) ]

**View the tags of a keyspace using CQL**

To read the tags attached to a keyspace, use the following CQL statement.

```
SELECT * FROM system_schema_mcs.tags WHERE valid_where_clause;
```

The `WHERE` clause is required, and must use one of the following formats:
+ `keyspace_name = 'mykeyspace' AND resource_type = 'keyspace'`
+ `resource_id = arn`
+ The following statement shows whether a keyspace has tags.

  ```
  SELECT * FROM system_schema_mcs.tags WHERE keyspace_name = 'mykeyspace' AND resource_type = 'keyspace';
  ```

  The output of the query looks like the following.

  ```
  resource_id                                                      | keyspace_name | resource_name | resource_type | tags
  -----------------------------------------------------------------+---------------+---------------+---------------+------
  arn:aws:cassandra:us-east-1:111122223333:/keyspace/mykeyspace/      | mykeyspace    | mykeyspace    | keyspace      | {'key1': 'val1', 'key2': 'val2'}
  ```

------
#### [ CLI ]

**View the tags of a keyspace using the AWS CLI**
+ This example shows how to list the tags of the specified resource.

  ```
  aws keyspaces list-tags-for-resource --resource-arn 'arn:aws:cassandra:us-east-1:111122223333:/keyspace/myKeyspace/'
  ```

  The output of the last command looks like this.

  ```
  {
      "tags": [
          {
              "key": "key1",
              "value": "val1"
          },
          {
              "key": "key2",
              "value": "val2"
          },
          {
              "key": "key3",
              "value": "val3"
          },
          {
              "key": "key4",
              "value": "val4"
          }
      ]
  }
  ```

------

# Add tags when creating a new table
<a name="Tagging.Operations.new.table"></a>

You can use the Amazon Keyspaces console, CQL or the AWS CLI to add tags to new tables when you create them. 

------
#### [ Console ]

**Add a tag when creating a new table using the (console)**

1. Sign in to the AWS Management Console, and open the Amazon Keyspaces console at [https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home).

1. In the navigation pane, choose **Tables**, and then choose **Create table**.

1. On the **Create table** page in the **Table details** section, select a keyspace and provide a name for the table.

1. In the **Schema** section, create the schema for your table.

1. In the **Table settings** section, choose **Customize settings**.

1. Continue to the **Table tags – *optional*** section, and choose **Add new tag** to create new tags.

1. Choose **Create table**.

------
#### [ Cassandra Query Language (CQL) ]

**Add tags when creating a new table using CQL**
+ The following example creates a new table with tags.

  ```
  CREATE TABLE mytable(...) WITH TAGS = {'key1':'val1', 'key2':'val2'};
  ```

------
#### [ CLI ]

**Add tags when creating a new table using the AWS CLI**
+ The following example shows how to create a new table with tags. The command creates a table *myTable* in an already existing keyspace *myKeyspace*. Note that the command has been broken up into different lines to help with readability.

  ```
  aws keyspaces create-table --keyspace-name 'myKeyspace' --table-name 'myTable' 
              --schema-definition 'allColumns=[{name=id,type=int},{name=name,type=text},{name=date,type=timestamp}],partitionKeys=[{name=id}]' 
              --tags 'key=key1,value=val1' 'key=key2,value=val2'
  ```

------

# Add tags to a table
<a name="Tagging.Operations.existing.table"></a>

You can add tags to an existing table in Amazon Keyspaces using the console, CQL or the AWS CLI.

------
#### [ Console ]

**Add tags to a table using the Amazon Keyspaces console**

1. Sign in to the AWS Management Console, and open the Amazon Keyspaces console at [https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home).

1. In the navigation pane, choose **Tables**.

1. Choose a table from the list and choose the **Tags** tab. 

1. Choose **Manage tags** to add tags to the table.

1. Choose **Save changes**.

------
#### [ Cassandra Query Language (CQL) ]

**Add tags to a table using CQL**
+ The following statement shows how to add tags to an existing table.

  ```
  ALTER TABLE mykeyspace.mytable ADD TAGS {'key1':'val1', 'key2':'val2'};
  ```

------
#### [ CLI ]

**Add tags to a table using the AWS CLI**
+ The following example shows how to add new tags to an existing table.

  ```
  aws keyspaces tag-resource --resource-arn 'arn:aws:cassandra:us-east-1:111122223333:/keyspace/myKeyspace/table/myTable' --tags 'key=key3,value=val3' 'key=key4,value=val4'
  ```

------

# Delete tags from a table
<a name="Tagging.Operations.existing.table.drop"></a>

------
#### [ Console ]

**Delete tags from a table using the Amazon Keyspaces console**

1. Sign in to the AWS Management Console, and open the Amazon Keyspaces console at [https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home).

1. In the navigation pane, choose **Tables**.

1. Choose a table from the list and choose the **Tags** tab. 

1. Choose **Manage tags** to delete tags from the table.

1. Choose **Save changes**.

------
#### [ Cassandra Query Language (CQL) ]

**Delete tags from a table using CQL**
+ The following statement shows how to delete tags from an existing table.

  ```
  ALTER TABLE mytable DROP TAGS {'key3':'val3', 'key4':'val4'};
  ```

------
#### [ CLI ]

**Add tags to a table using the AWS CLI**
+ The following statement removes the specified tags from a keyspace.

  ```
  aws keyspaces untag-resource --resource-arn 'arn:aws:cassandra:us-east-1:111122223333:/keyspace/myKeyspace/table/myTable' --tags 'key=key3,value=val3' 'key=key4,value=val4'
  ```

------

# View the tags of a table
<a name="Tagging.Operations.view.table"></a>

The following examples show how to view the tags of a table in Amazon Keyspaces using the console, CQL, or the AWS CLI.

------
#### [ Console ]

**View the tags of a table using the console**

1. Sign in to the AWS Management Console, and open the Amazon Keyspaces console at [https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home).

1. In the navigation pane, choose **Tables**.

1. Choose a table from the list and choose the **Tags** tab. 

------
#### [ Cassandra Query Language (CQL) ]

**View the tags of a table using CQL**

To read the tags attached to a table, use the following CQL statement.

```
SELECT * FROM system_schema_mcs.tags WHERE valid_where_clause;
```

The `WHERE` clause is required, and must use one of the following formats:
+ `keyspace_name = 'mykeyspace' AND resource_name = 'mytable'`
+ `resource_id = arn`
+ The following query returns the tags of the specified table.

  ```
  SELECT * FROM system_schema_mcs.tags WHERE keyspace_name = 'mykeyspace' AND resource_name = 'mytable';
  ```

  The output of that query looks like the following.

  ```
  resource_id                                                                 | keyspace_name | resource_name | resource_type | tags
  ----------------------------------------------------------------------------+---------------+---------------+---------------+------
  arn:aws:cassandra:us-east-1:111122223333:/keyspace/mykeyspace/table/mytable| mykeyspace    | mytable       | table         | {'key1': 'val1', 'key2': 'val2'}
  ```

------
#### [ CLI ]

**View the tags of a table using the AWS CLI**
+ This example shows how to list the tags of the specified resource.

  ```
  aws keyspaces list-tags-for-resource --resource-arn 'arn:aws:arn:aws:cassandra:us-east-1:111122223333:/keyspace/my_keyspace/table/my_table/stream/2025-05-11T21:21:33.291cassandra:us-east-1:111122223333:/keyspace/myKeyspace/table/myTable'
  ```

  The output of the last command looks like this.

  ```
  {
      "tags": [
          {
              "key": "key1",
              "value": "val1"
          },
          {
              "key": "key2",
              "value": "val2"
          },
          {
              "key": "key3",
              "value": "val3"
          },
          {
              "key": "key4",
              "value": "val4"
          }
      ]
  }
  ```

------

# Add tags to a new stream when creating a table
<a name="Tagging.Operations.new.table.stream"></a>

You can add tags to streams when you create a new table with a stream using CQL or the AWS CLI to tag a stream.

**Note**  
Amazon Keyspaces CDC requires the presence of a service-linked role (`AWSServiceRoleForAmazonKeyspacesCDC`) that publishes metric data from Amazon Keyspaces CDC streams into the `"cloudwatch:namespace": "AWS/Cassandra"` in your CloudWatch account on your behalf. This role is created automatically for you. For more information, see [Using roles for Amazon Keyspaces CDC streams](using-service-linked-roles-CDC-streams.md).

------
#### [ Cassandra Query Language (CQL) ]

**Add tags to a stream when creating a new table using CQL**

1. To create a new table with a stream and apply the table tags automatically to the stream, you can use the `'propagate_tags': 'TABLE'` flag. The following statement is an example of this.

   ```
   CREATE TABLE mytable (pk int, ck text, PRIMARY KEY(pk))
   WITH TAGS={'key1':'val1', 'key2':'val2'}
   AND cdc = TRUE
   AND CUSTOM_PROPERTIES={
       'cdc_specification': {
           'view_type': 'NEW_IMAGE',
           'propagate_tags': 'TABLE'
       }
   };
   ```

1. To apply new tags to the stream, you can use the following example.

   ```
   CREATE TABLE mytable (pk int, ck text, PRIMARY KEY(pk))
   WITH TAGS={'key1':'val1', 'key2':'val2'}
   AND cdc = TRUE
   AND CUSTOM_PROPERTIES={
       'cdc_specification': {
           'view_type': 'NEW_IMAGE',
           'tags': { 'key': 'string', 'value': 'string' },
       }
   };
   ```

------
#### [ CLI ]

**Add tags to a stream when creating a new table using the AWS CLI**

1. To create a table with a stream and apply the table tags automatically to the stream, you can use the `propagateTags=Table` flag. The following code is an example of this.

   ```
   aws keyspaces create-table \
   --keyspace-name 'my_keyspace' \
   --table-name 'my_table' \
   --schema-definition 'allColumns=[{name=pk,type=int},{name=ck,type=text}],clusteringKeys=[{name=ck,orderBy=ASC}],partitionKeys=[{name=pk}]' \
   --tags key=tag_key,value=tag_value
   --cdc-specification propagateTags=TABLE,status=ENABLED,viewType=NEW_IMAGE
   ```

1. To apply different tags to the stream, you can use the following example.

   ```
   aws keyspaces create-table \
   --keyspace-name 'my_keyspace' \
   --table-name 'my_table' \
   --schema-definition 'allColumns=[{name=pk,type=int},{name=ck,type=text}],clusteringKeys=[{name=ck,orderBy=ASC}],partitionKeys=[{name=pk}]' \
   --tags key=tag_key,value=tag_value 
   --cdc-specification 'status=ENABLED,viewType=NEW_IMAGE,tags=[{key=tag_key, value=tag_value}]'
   ```

------

# Add tags to a new stream for an existing table
<a name="Tagging.Operations.new.stream"></a>

You can add tags when you create a new stream for an existing table. You can either use the `PropagateTags` flag to apply the table tags to the stream or specify new tags for the stream. You can use CQL or the AWS CLI to tag a new stream.

**Note**  
Amazon Keyspaces CDC requires the presence of a service-linked role (`AWSServiceRoleForAmazonKeyspacesCDC`) that publishes metric data from Amazon Keyspaces CDC streams into the `"cloudwatch:namespace": "AWS/Cassandra"` in your CloudWatch account on your behalf. This role is created automatically for you. For more information, see [Using roles for Amazon Keyspaces CDC streams](using-service-linked-roles-CDC-streams.md).

------
#### [ Console ]

**Add tags when creating a new stream using the (console)**

1. Sign in to the AWS Management Console, and open the Amazon Keyspaces console at [https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home).

1. In the navigation pane, choose **Tables**, and then choose the table you want to add a stream for.

1. Choose the **Streams** tab.

1. In the **Stream details** section, choose **Edit**.

1. Select **Turn on streams** .

1. Select the **View type** and continue to **Tags** to create tags for the stream.

1. You can select one of the following options:
   + **No tags** – Use this option if you don't want to create any tags for the stream.
   + **Copy tags from table** – Use this option if you want to copy the tags from the table to the stream. After copying the tags, you can edit them for the stream. Note that this option is only available if the table has tags.
   + **Add new tags** – You can add up to 50 tags for the stream by choosing **Add new tag**.

1. Choose **Save changes**.

------
#### [ Cassandra Query Language (CQL) ]

**Add tags when creating a new stream**

1. To create a new stream for an existing table and apply the table's tags to the stream, you can use the `'propagate_tags': 'TABLE'` flag. The following statements is an example of this.

   ```
   ALTER TABLE mytable WITH cdc = TRUE AND CUSTOM_PROPERTIES={ 'cdc_specification': { 'view_type': 'NEW_IMAGE', 'propagate_tags': 'TABLE' } };
   ```

1. To create a new stream for an existing table and specify new tags, you can use the following example.

   ```
   ALTER TABLE mytable WITH cdc = TRUE AND CUSTOM_PROPERTIES={ 'cdc_specification': { 'view_type': 'NEW_IMAGE', 'tags': { 'key': 'string', 'value': 'string' }} };
   ```

------
#### [ CLI ]

**Add tags when creating a new stream using the AWS CLI**

1. To create a new stream with tags, you can use the `propagateTags=TABLE` flag to apply the table's tags automatically to the stream. The following code is an example of this.

   ```
   aws keyspaces update-table \ 
   --keyspace-name 'my_keyspace' \ 
   --table-name 'my_table' \
   --cdc-specification propagateTags=TABLE,status=ENABLED,viewType=NEW_IMAGE
   ```

1. To create a new stream for an existing table and specify new tags, you can use the following example.

   ```
   aws keyspaces update-table \ 
   --keyspace-name 'my_keyspace' \ 
   --table-name 'my_table' \
   --cdc-specification 'status=ENABLED,viewType=NEW_IMAGE,tags=[{key=tag_key, value=tag_value}]'
   ```

------

# Add new tags to a stream
<a name="Tagging.Operations.existing.stream"></a>

You can add new tags to an existing stream in Amazon Keyspaces using the CQL or the AWS CLI. You can only add tags to the latest stream.

------
#### [ Console ]

**Add tags to an existing stream (console)**

1. Sign in to the AWS Management Console, and open the Amazon Keyspaces console at [https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home).

1. In the navigation pane, choose **Tables**, and then choose the table with the stream that you want to tag.

1. Choose the **Streams** tab.

1. In the **Tags** section, choose **Manage tags**.

1. Choose **Add new tag** to add a new tag. You can create up to 50 tags by repeating this step.

1. Choose **Save changes**.

------
#### [ Cassandra Query Language (CQL) ]

**Add tags to a stream using CQL**
+ The following statement shows how to add tags to an existing stream.

  ```
  ALTER TABLE mykeyspace.mytable ADD TAGS_FOR_CDC {'key1':'val1', 'key2':'val2'};
  ```

------
#### [ CLI ]

**Add tags to a stream using the AWS CLI**
+ The following example shows how to add new tags to an existing stream.

  ```
  aws keyspaces tag-resource --resource-arn 'arn:aws:cassandra:us-east-1:111122223333:/keyspace/my_keyspace/table/my_table/stream/2025-05-11T21:21:33.291' --tags 'key=key3,value=val3' 'key=key4,value=val4'
  ```

------

# Delete tags from a stream
<a name="Tagging.Operations.existing.stream.drop"></a>

To delete tags from a stream, you can use CQL or the AWS CLI. You can only delete the tags for the latest stream. 

------
#### [ Console ]

**Delete tags from a table using the Amazon Keyspaces console**

1. Sign in to the AWS Management Console, and open the Amazon Keyspaces console at [https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home).

1. In the navigation pane, choose **Tables**.

1. Choose a table from the list and choose the **Streams** tab. 

1. In the **Tags** section choose **Manage tags** to delete tags from the table.

1. After the tag you want to delete, choose **Remove**.

1. Choose **Save changes**.

------
#### [ Cassandra Query Language (CQL) ]

**Delete tags from a stream using CQL**
+ The following statement shows how to delete tags from an existing stream.

  ```
  ALTER TABLE mytable DROP TAGS_FOR_CDC {'key3':'val3', 'key4':'val4'};
  ```

------
#### [ CLI ]

**Delete tags from a stream using the AWS CLI**
+ The following statement removes the specified tags from a stream.

  ```
  aws keyspaces untag-resource --resource-arn 'arn:aws:cassandra:us-east-1:111122223333:/keyspace/my_keyspace/table/my_table/stream/2025-05-11T21:21:33.291' --tags 'key=key3,value=val3' 'key=key4,value=val4'
  ```

------

# View the tags of a stream
<a name="Tagging.Operations.view.stream"></a>

The following examples show how to view the tags of a stream in Amazon Keyspaces using CQL or the AWS CLI.

------
#### [ Console ]

**View the tags of a stream using the console**

1. Sign in to the AWS Management Console, and open the Amazon Keyspaces console at [https://console.aws.amazon.com/keyspaces/home](https://console.aws.amazon.com/keyspaces/home).

1. In the navigation pane, choose **Tables**.

1. Choose a table from the list and choose the **Streams** tab. 

1. You can view the tags of the stream in the **Tags** section.

------
#### [ Cassandra Query Language (CQL) ]

**View the tags of a stream using CQL**

To read the tags attached to a stream, you must specify the resource ARN of the stream in the `WHERE` clause. The following CQL syntax is an example of this.

```
SELECT * FROM system_schema_mcs.tags WHERE resource_id = stream_arn;
```
+ The following query returns the tags for the specified stream.

  ```
  SELECT tags FROM system_schema_mcs.tags WHERE resource_id = 'arn:aws:cassandra:us-east-1:111122223333:/keyspace/my_keyspace/table/my_table/stream/2025-05-06T17:17:39.800';
  ```

  The output of that query looks like the following.

  ```
   resource_id                                                                                                       | keyspace_name | resource_name           | resource_type | tags   
   ------------------------------------------------------------------------------------------------------------------+---------------+-------------------------+---------------+---------------------- 
   arn:aws:cassandra:us-east-1:111122223333:/keyspace/my_keyspace/table/my_table/stream/2025-04-02T23:00:07.052     |      singleks | 2025-04-02T23:00:07.052 |        stream | {'tagkey': 'tagval'}
  ```

------
#### [ CLI ]

**View the tags of a stream using the AWS CLI**
+ This example shows how to list the tags for all streams under the specified keyspace.

  ```
  aws keyspaces list-tags-for-resource --resource-arn 'arn:aws:cassandra:us-east-1:111122223333:/keyspace/my_keyspace/table/my_table/stream/2025-05-11T21:21:33.291'
  ```

  The output of the last command looks like this.

  ```
  {
      "tags": [
          {
              "key": "key1",
              "value": "val1"
          },
          {
              "key": "key2",
              "value": "val2"
          },
          {
              "key": "key3",
              "value": "val3"
          },
          {
              "key": "key4",
              "value": "val4"
          }
      ]
  }
  ```

------

# Create cost allocation reports using tags for Amazon Keyspaces
<a name="CostAllocationReports"></a>

AWS uses tags to organize resource costs on your cost allocation report. AWS provides two types of cost allocation tags:
+ An AWS-generated tag. AWS defines, creates, and applies this tag for you.
+ User-defined tags. You define, create, and apply these tags.

You must activate both types of tags separately before they can appear in Cost Explorer or on a cost allocation report. 

 To activate AWS-generated tags: 

1.  Sign in to the AWS Management Console and open the Billing and Cost Management console at [https://console.aws.amazon.com/billing/home\$1/.](https://console.aws.amazon.com/billing/home#/) 

1.  In the navigation pane, choose **Cost Allocation Tags**. 

1.  Under **AWS-Generated Cost Allocation Tags**, choose **Activate**. 

 To activate user-defined tags: 

1.  Sign in to the AWS Management Console and open the Billing and Cost Management console at [https://console.aws.amazon.com/billing/home\$1/.](https://console.aws.amazon.com/billing/home#/) 

1.  In the navigation pane, choose **Cost Allocation Tags**. 

1.  Under **User-Defined Cost Allocation Tags**, choose **Activate**. 

 After you create and activate tags, AWS generates a cost allocation report with your usage and costs grouped by your active tags. The cost allocation report includes all of your AWS costs for each billing period. The report includes both tagged and untagged resources, so that you can clearly organize the charges for resources. 

**Note**  
 Currently, any data transferred out from Amazon Keyspaces won't be broken down by tags on cost allocation reports. 

 For more information, see [Using cost allocation tags](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html). 