

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 標記您的 AWS IoT 資源
<a name="tagging-iot"></a>

為了協助您管理和組織物件群組、物件類型、主題規則、任務、排程稽核及安全性描述檔，您可以選擇性地以標籤形式將您自己的中繼資料指派給其中每個資源。本節說明標籤並示範如何建立它們。

為了協助您管理與物件相關的成本，您可以建立包含物件的[帳單群組](tagging-iot-billing-groups.md)。您可以將包括中繼資料的標籤指派到每個帳單群組。本節也會討論可用來建立和管理的帳單群組和命令。

## 標籤基本概念
<a name="tagging-iot-basics"></a>

您可以使用標籤，以不同的方式 （例如，依用途、擁有者或環境） 分類 AWS IoT 資源。當您有許多相同類型的資源時，這會很有用，因為您可以依據先前指派的標籤快速識別資源。每個標籤皆包含由您定義的一個「索引鍵」與選擇性的「值」。例如，您可以為您的物件類型定義一組標籤，協助您以類型追蹤裝置。我們建議您為每種資源類型建立符合您需求的一組標籤金鑰。使用一致的標籤金鑰組可讓您更輕鬆管理您的 資源。

您可以根據新增或套用的標籤來搜尋與篩選資源。您也可以使用帳單群組標籤來分類和追蹤您的成本。您也可以使用標籤來控制對您資源的存取，如 [搭配 IAM 政策使用標籤](tagging-iot-iam.md) 所述。

為了方便使用， AWS 管理主控台中的標籤編輯器提供集中、統一的方式來建立和管理標籤。如需詳細資訊，請參閱[使用標籤編輯器](https://docs.aws.amazon.com/awsconsolehelpdocs/latest/gsg/tag-editor.html)[使用 AWS 管理主控台](https://docs.aws.amazon.com/awsconsolehelpdocs/latest/gsg/getting-started.html)。

您也可以使用 AWS CLI 和 AWS IoT API 處理標籤。當您使用下列命令在 `Tags` 欄位中建立標籤時，您可將標籤與物件群組、物件類型、主題規則、任務、安全性設定檔、政策、帳單群組、物件相關套件和版本建立關聯：
+ [CreateBillingGroup](https://docs.aws.amazon.com//iot/latest/apireference/API_CreateBillingGroup)
+ [CreateDestination](https://docs.aws.amazon.com//iot-wireless/latest/apireference/API_CreateDestination.html)
+ [CreateDeviceProfile](https://docs.aws.amazon.com//iot-wireless/latest/apireference/API_CreateDeviceProfile.html)
+ [CreateDynamicThingGroup](https://docs.aws.amazon.com//iot/latest/apireference/API_CreateDynamicThingGroup)
+ [CreateJob](https://docs.aws.amazon.com//iot/latest/apireference/API_CreateJob)
+ [CreateOTAUpdate](https://docs.aws.amazon.com//iot/latest/apireference/API_CreateOTAUpdate)
+ [CreatePolicy](https://docs.aws.amazon.com//iot/latest/apireference/API_CreatePolicy.html)
+ [CreateScheduledAudit](https://docs.aws.amazon.com//iot/latest/apireference/API_CreateScheduledAudit)
+ [CreateSecurityProfile](https://docs.aws.amazon.com//iot/latest/apireference/API_CreateSecurityProfile)
+ [CreateServiceProfile](https://docs.aws.amazon.com//iot-wireless/latest/apireference/API_CreateServiceProfile.html)
+ [CreateStream](https://docs.aws.amazon.com//iot/latest/apireference/API_CreateStream)
+ [CreateThingGroup](https://docs.aws.amazon.com//iot/latest/apireference/API_CreateThingGroup)
+ [CreateThingType](https://docs.aws.amazon.com//iot/latest/apireference/API_CreateThingType)
+ [CreateTopicRule](https://docs.aws.amazon.com//iot/latest/apireference/API_CreateTopicRule)
+ [CreateWirelessGateway](https://docs.aws.amazon.com//iot-wireless/latest/apireference/API_CreateWirelessGateway.html)
+ [CreateWirelessDevice](https://docs.aws.amazon.com//iot-wireless/latest/apireference/API_CreateWirelessDevice.html)

您可以使用下列命令新增、修改或刪除支援標記功能的現有資源標籤：
+ [TagResource](https://docs.aws.amazon.com//iot/latest/apireference/API_TagResource)
+ [ListTagsForResource](https://docs.aws.amazon.com//iot/latest/apireference/API_ListTagsForResource)
+ [UntagResource](https://docs.aws.amazon.com//iot/latest/apireference/API_UntagResource)

您可以編輯標籤索引鍵和值，也可以隨時從資源中移除標籤。您可以將標籤的值設為空白字串，但您無法將標籤的值設為 Null。如果您新增的標籤具有與該資源上現有標籤相同的索引鍵，則新值會覆寫舊值。如果您刪除資源，也會刪除與該資源相關聯的任何標籤。

### 標籤的限制與上限
<a name="tagging-iot-restrict"></a>

以下基本限制適用於 標籤：
+ 每個資源的標籤數上限：50
+ 金鑰長度上限：127 個 UTF-8 Unicode 字元
+ 值長度上限：255 個 UTF-8 Unicode 字元
+ 標籤鍵與值皆區分大小寫。
+ 請勿於標籤名稱或值中使用 `aws:` 字首。它保留供 AWS 使用。您不可編輯或刪除具此字首的標籤名稱或值。具此字首的標籤，不算在受資源限制的標籤計數內。
+ 如果您的標記結構描述是跨多項服務和資源使用，請記得其他服務可能會有字元使用限制。允許使用的字元包括可用 UTF-8 表示的英文字母、空格和數字，以及以下特殊字元：\$1 - = . \$1 : / @。