

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

# 使用 Amazon SageMaker API 管理私有人力資源
<a name="sms-workforce-management-private-api"></a>

您可以使用 Amazon SageMaker API 作業來管理、更新和刪除私有人力資源。對於以下主題列出的每個 API 作業，您可以在 API 文件的**另請參閱**一節中找到支援的特定語言 SDK 及其文件的清單。

**Topics**
+ [尋找您的人力資源名稱](sms-workforce-management-private-api-name.md)
+ [將工作者任務存取限制為允許的 IP 位址](sms-workforce-management-private-api-cidr.md)
+ [啟用雙堆疊人力資源](sms-workforce-management-private-api-dualstack.md)
+ [更新 OIDC 身分提供者人力資源組態](sms-workforce-management-private-api-update.md)
+ [刪除私有人力資源](sms-workforce-management-private-api-delete.md)

# 尋找您的人力資源名稱
<a name="sms-workforce-management-private-api-name"></a>

某些 SageMaker AI 人力資源相關的 API 作業需要您的人力資源名稱作為輸入。您可以使用該區域中 AWS 的 []() API 操作，在 區域中查看 Amazon Cognito 或 OIDC IdP 私有和廠商人力資源名稱 AWS 。如果您使用自己的 OIDC IdP 建立人力資源，則可以在 SageMaker AI 主控台的 Ground Truth 區域中找到人力資源名稱。

**若要在 SageMaker AI 主控台尋找您的人力資源名稱**

1. 前往 SageMaker AI 主控台的 Ground Truth 區域：[https://console.aws.amazon.com/sagemaker/groundtruth](https://console.aws.amazon.com/sagemaker/groundtruth)。

1. 選取**標籤人力資源**。

1. 選取**私有**。

1. 在**私有人力資源摘要**區段中，找到您的人力資源 ARN。您的人力資源名稱位於此 ARN 的末尾。例如，如果 ARN 是 `arn:aws:sagemaker:us-east-2:111122223333:workforce/example-workforce`，則人力資源名稱為 `example-workforce`。

# 將工作者任務存取限制為允許的 IP 位址
<a name="sms-workforce-management-private-api-cidr"></a>

根據預設，人力資源不會侷限於特定 IP 位址。您可以使用 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateWorkforce.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateWorkforce.html) 操作，要求工作者使用特定範圍的 IP 位址 ([CIDR](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html)) 來存取任務。如果您指定一或多個 CIDR，則嘗試使用指定範圍以外的任何 IP 位址來存取任務的工作者會遭到拒絕，並且會在工作者入口網站上收到 HTTP 204 無內容錯誤訊息。使用 `UpdateWorkforce` 最多可以指定 10 個 CIDR 值。

將人力資源限制在一或多個 CIDR 之後，`UpdateWorkforce` 輸出會列出所有允許的 CIDR。您也可以使用 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeWorkforce.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeWorkforce.html) 作業來檢視人力資源所有允許的 CIDR。

# 啟用雙堆疊人力資源
<a name="sms-workforce-management-private-api-dualstack"></a>

您可以使用 [CreateWorkforce](https://docs.aws.amazon.com//sagemaker/latest/APIReference/API_CreateWorkforce.html) 和 [UpdateWorkforce](https://docs.aws.amazon.com//sagemaker/latest/APIReference/API_UpdateWorkforce.html) API 操作來啟用雙堆疊人力資源。 AWS 管理主控台不支援建立雙堆疊人力資源、將現有人力資源更新為雙堆疊，以及將人力資源從雙堆疊變更回 IPv4。

**重要**  
沒有定義 `IpAddressType` 的人力資源預設為 `IPv4`。

## 建立雙堆疊人力資源
<a name="sms-workforce-management-private-dualstack-create"></a>

建立雙堆疊人力資源的程序類似於建立僅 IPv4 的人力資源，但有下列例外。如需詳細資訊，請參閱 [CreateWorkforce](https://docs.aws.amazon.com//sagemaker/latest/APIReference/API_CreateWorkforce.html)。
+ 若要將 VPC 連接到私有人力資源，請確定 VPC 也是雙堆疊，並具有與 VPC 子網路相關聯的 IPv6 CIDR 區塊。
+ 若要使用 `SourceIpConfig` 參數將流量限制在特定 IP 位址範圍，請確定 IPv6 CIDR 區塊也包含在清單中。
+ 若要在任務存取的 S3 儲存貯體上實作具 `SourceIp` 條件的政策，請確保這些政策已更新為相容於雙堆疊。
+ 身分提供者驗證端點支援雙堆疊。如需詳細資訊，請參閱[身分驗證流程​](https://docs.aws.amazon.com//elasticloadbalancing/latest/application/listener-authenticate-users.html#authentication-flow)。

**使用 boto3 的 `CreateWorkforce` SDK 呼叫範例**

如需詳細資訊，請參閱 [create\$1workforce](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker/client/create_workforce.html#SageMaker.Client.create_workforce)。

```
import boto3

client = boto3.resource('sagemaker')

# IpAddressType = 'dualstack'|'ipv4'
client.create_workforce(
    WorkforceName='string',
    IpAddressType='dualstack',
    WorkforceConfig={
        'CognitoConfig': {
            'UserPool': 'string',
            'Client': 'string'
        }
    }
)
```

## 更新雙堆疊人力資源
<a name="sms-workforce-management-private-dualstack-update"></a>

將現有人力資源更新為雙堆疊時，請注意下列事項。如需詳細資訊，請參閱 [UpdateWorkforce](https://docs.aws.amazon.com//sagemaker/latest/APIReference/API_UpdateWorkforce.html) 和 [VPC 的 IPv6 支援](https://docs.aws.amazon.com//vpc/latest/userguide/vpc-migrate-ipv6.html)。
+ 如果 VPC 連接到人力資源，您必須將 VPC 更新為雙堆疊。請同時確保 VPC 的任何安全群組都允許 IPv6 流量。
+ 如果您使用 `SourceIpConfig` 參數，請將其更新為包含 IPv6 CIDR 區塊。
+ 若要在任務存取的 S3 儲存貯體上實作具 `SourceIp` 條件的政策，請確保這些政策已更新為相容於雙堆疊。
+ 身分提供者驗證端點支援雙堆疊。如需詳細資訊，請參閱[身分驗證流程​](https://docs.aws.amazon.com//elasticloadbalancing/latest/application/listener-authenticate-users.html#authentication-flow)。

**使用 boto3 的 `UpdateWorkforce` SDK 呼叫範例**

如需詳細資訊，請參閱 [update\$1workforce](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker/client/update_workforce.html#SageMaker.Client.update_workforce)。

```
import boto3

client = boto3.resource('sagemaker')

# IpAddressType = 'dualstack'|'ipv4'
client.update_workforce(
    WorkforceName='string',
    IpAddressType='dualstack'
)
```

# 更新 OIDC 身分提供者人力資源組態
<a name="sms-workforce-management-private-api-update"></a>

您可能想要更新使用自己的 OIDC IdP 建立的人力資源，以指定不同的授權端點、權杖端點或發行者。您可以使用 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateWorkforce.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateWorkforce.html) 作業更新在 `[OidcConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_OidcConfig.html)` 中找到的任何參數。

**重要**  
僅可在無工作團隊與人力資源建立關聯時更新 OIDC IdP 組態。您可以使用 `[DeleteWorkteam](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteWorkteam.html)` 作業刪除私有工作團隊。

# 刪除私有人力資源
<a name="sms-workforce-management-private-api-delete"></a>

每個 AWS 區域中只能有一個私有人力資源。在以下 AWS 情況下，您可能想要刪除 區域中的私有人力資源：
+ 您希望使用新的 Amazon Cognito 使用者集區建立人力資源。
+ 您已經使用 Amazon Cognito 建立私有人力資源，而且希望使用自己的 OpenID Connect (OIDC) 身分提供者 (IdP) 建立人力資源。

若要刪除私有人力資源，請使用 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteWorkforce.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteWorkforce.html) API 作業。如果您有任何與人力資源關聯的工作團隊，則必須先刪除這些工作團隊，然後再刪除人力資源。您可以使用 `[DeleteWorkteam](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteWorkteam.html)` 作業刪除私有工作團隊。