

# Tagging collections (Amazon CLI)
<a name="tag-collection-cli"></a>

To tag a collection using the Amazon CLI, send a [TagResource](https://docs.amazonaws.cn/opensearch-service/latest/ServerlessAPIReference/API_TagResource.html) request: 

```
aws opensearchserverless tag-resource
  --resource-arn arn:aws:aoss:{{us-east-1}}:{{123456789012}}:collection/{{my-collection}} 
  --tags Key={{service}},Value={{aoss}} Key={{source}},Value={{logs}}
```

View the existing tags for a collection with the [ListTagsForResource](https://docs.amazonaws.cn/opensearch-service/latest/ServerlessAPIReference/API_ListTagsForResource.html) command:

```
aws opensearchserverless list-tags-for-resource
  --resource-arn arn:aws:aoss:{{us-east-1}}:{{123456789012}}:collection/{{my-collection}}
```

Remove tags from a collection using the [UntagResource](https://docs.amazonaws.cn/opensearch-service/latest/ServerlessAPIReference/API_UntagResource.html) command:

```
aws opensearchserverless untag-resource
  --resource-arn arn:aws:aoss:{{us-east-1}}:{{123456789012}}:collection/{{my-collection}}
  --tag-keys {{service}}
```