

# Updating tags for Amazon Cloud Map resources
<a name="tag-resources-api-sdk"></a>

Use the following Amazon CLI commands or Amazon Cloud Map API operations to add, update, list, and delete the tags for your resources.


**Tagging support for Amazon Cloud Map resources**  

| Task | API action | Amazon CLI | Amazon Tools for Windows PowerShell | 
| --- | --- | --- | --- | 
| Add or overwrite one or more tags. | [TagResource](https://docs.amazonaws.cn/cloud-map/latest/api/API_TagResource.html) | [tag-resource](https://docs.amazonaws.cn/cli/latest/reference/servicediscovery/tag-resource.html) | [Add-SDResourceTag](https://docs.amazonaws.cn/powershell/v4/reference/items/Add-SDResourceTag.html) | 
| Delete one or more tags. | [UntagResource](https://docs.amazonaws.cn/cloud-map/latest/api/API_UntagResource.html) | [untag-resource](https://docs.amazonaws.cn/cli/latest/reference/servicediscovery/untag-resource.html) | [Remove-SDResourceTag](https://docs.amazonaws.cn/powershell/v4/reference/items/Remove-SDResourceTag.html) | 
| List tags for a resource | [ListTagsForResource](https://docs.amazonaws.cn/cloud-map/latest/api/API_ListTagsForResource.html) | [list-tags-for-resource](https://docs.amazonaws.cn/cli/latest/reference/servicediscovery/list-tags-for-resource.html) | [Get-SDResourceTag](https://docs.amazonaws.cn/powershell/v4/reference/items/Get-SDResourceTag.html) | 

The following examples show how to tag or untag resources using the Amazon CLI.

**Example 1: Tag an existing resource**  
The following command tags an existing resource.

```
aws servicediscovery tag-resource --resource-arn {{resource_ARN}} --tags {{team}}={{devs}}
```

**Example 2: Untag an existing resource**  
The following command deletes a tag from an existing resource.

```
aws servicediscovery untag-resource --resource-arn {{resource_ARN}} --tag-keys {{tag_key}}
```

**Example 3: List tags for a resource**  
The following command lists the tags associated with an existing resource.

```
aws servicediscovery list-tags-for-resource --resource-arn {{resource_ARN}}
```

Some resource-creating actions enable you to specify tags when you create the resource. The following actions support tagging on creation.


| Task | API action | Amazon CLI | Amazon Tools for Windows PowerShell | 
| --- | --- | --- | --- | 
| Create an HTTP namespace | [CreateHttpNamespace](https://docs.amazonaws.cn/cloud-map/latest/api/API_CreateHttpNamespace.html) | [create-http-namespace](https://docs.amazonaws.cn/cli/latest/reference/servicediscovery/create-http-namespace.html) | [New-SDHttpNamespace](https://docs.amazonaws.cn/powershell/v4/reference/items/New-SDHttpNamespace.html) | 
| Create a private namespace based on DNS | [CreatePrivateDnsNamespace](https://docs.amazonaws.cn/cloud-map/latest/api/API_CreatePrivateDnsNamespace.html) | [create-private-dns-namespace](https://docs.amazonaws.cn/cli/latest/reference/servicediscovery/create-private-dns-namespace.html) | [New-SDPrivateDnsNamespace](https://docs.amazonaws.cn/powershell/v4/reference/items/New-SDPrivateDnsNamespace.html) | 
| Create a public namespace based on DNS | [CreatePublicDnsNamespace](https://docs.amazonaws.cn/cloud-map/latest/api/API_CreatePublicDnsNamespace.html) | [create-public-dns-namespace](https://docs.amazonaws.cn/cli/latest/reference/servicediscovery/create-public-dns-namespace.html) | [New-SDPublicDnsNamespace](https://docs.amazonaws.cn/powershell/v4/reference/items/New-SDPublicDnsNamespace.html) | 
| Create a service | [CreateService](https://docs.amazonaws.cn/cloud-map/latest/api/API_CreateService.html) | [create-service](https://docs.amazonaws.cn/cli/latest/reference/servicediscovery/create-service.html) | [New-SDService](https://docs.amazonaws.cn/powershell/v4/reference/items/New-SDService.html) | 