

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

# 搭配 Amazon FSx 使用標籤
<a name="using-tags-fsx"></a>

您可以使用標籤來控制對 Amazon FSx 資源的存取，以及實作屬性型存取控制 (ABAC)。使用者需要有許可，才能在建立期間將標籤套用至 Amazon FSx 資源。

## 在建立期間授予標籤資源的許可
<a name="supported-iam-actions-tagging"></a>

有些建立資源的 FSx for Windows File Server API 動作可讓您在建立資源時指定標籤。您可以使用資源標籤來實作屬性型存取控制 (ABAC)。如需詳細資訊，請參閱《*IAM 使用者指南*》中的[什麼是 ABAC for AWS](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction_attribute-based-access-control.html)。

使用者若要在建立時標記資源，他們必須具備建立資源動作 (如 `fsx:CreateFileSystem` 或 `fsx:CreateBackup`) 的使用許可。若標籤於資源建立動作指定，Amazon 會針對 `fsx:TagResource` 動作執行其他授權，以確認使用者具備建立標籤的許可。因此，使用者必須同時具備使用 `fsx:TagResource` 動作的明確許可。

下列範例示範的政策可讓使用者在特定 中建立檔案系統，並將標籤套用至檔案系統 AWS 帳戶。

```
{
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
         "fsx:CreateFileSystem",
         "fsx:TagResource"         
      ],
      "Resource": "arn:aws:fsx:region:account-id:file-system/*"
    }
  ]
}
```

同樣地，以下政策允許使用者在特定檔案系統上建立備份，並在備份建立期間將任何標籤套用至備份。

```
{
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
         "fsx:CreateBackup"
      ],
      "Resource": "arn:aws:fsx:region:account-id:file-system/file-system-id*"
    },
    {
      "Effect": "Allow",
      "Action": [
         "fsx:TagResource"
      ],
      "Resource": "arn:aws:fsx:region:account-id:backup/*"
    }
  ]
}
```

只有在資源建立動作中套用了標籤時，才評估 `fsx:TagResource` 動作。因此，在沒有標記條件的情況下，若請求中未指定標籤，則具備資源建立許可的使用者不需要使用 `fsx:TagResource` 動作的許可。然而，若該使用者試圖建立具有標籤的資源卻未具備使用 `fsx:TagResource` 動作的許可，則該請求會失敗。

如需標記 Amazon FSx 資源的詳細資訊，請參閱 [標記 Amazon FSx 資源](tag-resources.md)。如需使用標籤控制 FSx 資源存取的詳細資訊，請參閱[使用標籤來控制對 Amazon FSx 資源的存取](#restrict-fsx-access-tags)。

## 使用標籤來控制對 Amazon FSx 資源的存取
<a name="restrict-fsx-access-tags"></a>

若要控制對 Amazon FSx 資源和動作的存取，您可以根據標籤使用 AWS Identity and Access Management (IAM) 政策。您可以透過兩個方式提供控制：

1. 根據這些資源上的標籤控制對 Amazon FSx 資源的存取。

1. 控制您可以在 IAM 請求條件中傳遞哪些標籤。

如需如何使用標籤來控制 AWS 資源存取的資訊，請參閱《*IAM 使用者指南*》中的[使用標籤控制存取](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_tags.html)。如需在建立時標記 Amazon FSx 資源的詳細資訊，請參閱 [在建立期間授予標籤資源的許可](#supported-iam-actions-tagging)。如需標記資源的詳細資訊，請參閱 [標記 Amazon FSx 資源](tag-resources.md)。

### 根據資源的標籤控制存取
<a name="resource-tag-control"></a>

若要控制使用者或角色可以在 Amazon FSx 資源上執行的動作，您可以在資源上使用標籤。例如，您可能想要根據資源上標籤的金鑰值組，允許或拒絕檔案系統資源上的特定 API 操作。

**Example 政策 – 提供特定標籤時在 上建立檔案系統**  
此政策允許使用者建立檔案系統，只有在它們使用特定標籤索引鍵值對標記它時，在此範例中為 `key=Department, value=Finance`。  

```
{
    "Effect": "Allow",
    "Action": [
        "fsx:CreateFileSystem",
        "fsx:TagResource"
    ],
    "Resource": "arn:aws:fsx:region:account-id:file-system/*",
    "Condition": {
        "StringEquals": {
            "aws:RequestTag/Department": "Finance"
        }
    }
}
```

**Example 政策 – 僅建立具有特定標籤的 Amazon FSx 檔案系統的備份**  
此政策允許使用者僅建立以金鑰值對 標記的檔案系統的備份`key=Department, value=Finance`，並使用標籤 建立備份`Deparment=Finance`。    
****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "fsx:CreateBackup"
            ],
            "Resource": "arn:aws:fsx:us-east-1:111122223333:file-system/*",
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/Department": "Finance"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "fsx:TagResource",
                "fsx:CreateBackup"
            ],
            "Resource": "arn:aws:fsx:us-east-1:111122223333:backup/*",
            "Condition": {
                "StringEquals": {
                    "aws:RequestTag/Department": "Finance"
                }
            }
        }
    ]
}
```

**Example 政策 – 從具有特定標籤的備份建立具有特定標籤的檔案系統**  
此政策允許使用者建立`Department=Finance`僅從使用 標記的備份加上 標記的檔案系統`Department=Finance`。    
****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "fsx:CreateFileSystemFromBackup",
                "fsx:TagResource"
            ],
            "Resource": "arn:aws:fsx:us-east-1:111122223333:backup/*",
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/Department": "Finance"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "fsx:CreateFileSystemFromBackup",
                "fsx:TagResource"
            ],
            "Resource": "arn:aws:fsx:us-east-1:111122223333:file-system/*",
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/Department": "Finance"
                }
            }
        }
    ]
}
```

**Example 政策 – 刪除具有特定標籤的檔案系統**  
此政策允許使用者僅刪除以 標記的檔案系統`Department=Finance`。如果他們建立最終備份，則必須使用 標記`Department=Finance`。    
****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "fsx:DeleteFileSystem"
            ],
            "Resource": "arn:aws:fsx:us-east-1:111122223333:file-system/*",
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/Department": "Finance"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "fsx:TagResource"
            ],
            "Resource": "arn:aws:fsx:us-east-1:111122223333:backup/*",
            "Condition": {
                "StringEquals": {
                    "aws:RequestTag/Department": "Finance"
                }
            }
        }
    ]
}
```