

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

# AWS Organizations – 標籤政策
<a name="aws-organizations-tag-policies"></a>

 中的政策 AWS Organizations 可讓您將其他類型的控管套用至組織中的 AWS 帳戶 。[https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_tag-policies.html](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_tag-policies.html)是以 JSON 格式表達標記結構描述的方式，讓平台可以在 AWS 您的環境中報告並選擇性地強制執行結構描述。標籤政策會定義特定資源類型上標籤索引鍵可接受的值。此政策可以是值清單的形式，或是前綴加上萬用字元 (`*`)。簡單字首方法不如分散的值清單嚴格，但需要的維護較少。

 下列範例示範如何定義標記政策，以驗證指定金鑰可接受的值。使用結構描述的人類友好表格式定義，您可以將此資訊轉錄為一或多個標籤政策。個別政策可用於支援委派所有權，或某些政策可能僅適用於特定案例。

## ExampleInc-CostAllocation.json
<a name="exampleinc-costallocation.json"></a>

 以下是報告成本分配標籤的標籤政策範例：

```
{
  "tags": {
    "example-inc:cost-allocation:ApplicationId": {
      "tag_key": {
        "@@assign": "example-inc:cost-allocation:ApplicationId"
      },
      "tag_value": {
        "@@assign": [
          "DataLakeX",
          "RetailSiteX"
        ]
      }
    },
    "example-inc:cost-allocation:BusinessUnitId": {
      "tag_key": {
        "@@assign": "example-inc:cost-allocation:BusinessUnitId"
      },
      "tag_value": {
        "@@assign": [
          "Architecture",
          "DevOps",
          "FinanceDataLakeX"
        ]
      }
    },
    "example-inc:cost-allocation:CostCenter": {
      "tag_key": {
        "@@assign": "example-inc:cost-allocation:CostCenter"
      },
      "tag_value": {
        "@@assign": [
          "123-*"
        ]
      }
    }
  }
}
```

## ExampleInc-DisasterRecovery.json
<a name="exampleinc-disasterrecovery.json"></a>

 以下是報告災難復原標籤的標籤政策範例：

```
{
    "tags": {
        "example-inc:disaster-recovery:rpo": {
            "tag_key": {
                "@@assign": "example-inc:disaster-recovery:rpo"
            },
            "tag_value": {
                "@@assign": [
                    "6h",
                    "24h"
                ]
            }
        }        
    }
}
```

 在此範例中，`ExampleInc-CostAllocation`標籤政策會連接至 `Workloads` OU，因此適用於 `Prod`和`Test`子 OUs 中的所有帳戶。同樣地，`ExampleInc-DisasterRecovery`標籤政策會連接至 `Prod` OU，因此僅適用於低於此 OU 的帳戶。[使用多個帳戶組織您的環境](https://docs.aws.amazon.com/whitepapers/latest/organizing-your-aws-environment/organizing-your-aws-environment.html)白皮書會更詳細地探索建議的 OU 結構。

![\[顯示標籤政策連接至 OU 結構和有效政策的圖表\]](http://docs.aws.amazon.com/zh_tw/whitepapers/latest/tagging-best-practices/images/adding-tagging-to-policies-in-ou-structure.png)


 查看圖表中的`marketing-prod`帳戶，這兩個標籤政策都適用於此帳戶，因此我們有*有效政策*的概念，這是適用於帳戶之指定類型政策的卷積。如果您主要手動管理您的資源，則可以造訪 主控台中的[資源群組和標籤編輯器：標籤政策來檢閱有效政策](https://console.aws.amazon.com/resource-groups/tag-policies)。如果您使用基礎設施做為程式碼 (IaC) 或指令碼來管理您的資源，您可以使用 [https://docs.aws.amazon.com/organizations/latest/APIReference/API_DescribeEffectivePolicy.html](https://docs.aws.amazon.com/organizations/latest/APIReference/API_DescribeEffectivePolicy.html) API 呼叫。