

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

# 使用介面端點存取 Amazon Cognito (AWS PrivateLink)
<a name="vpc-interface-endpoints"></a>

您可以使用 在 VPC 和 Amazon Cognito 之間 AWS PrivateLink 建立私有連線。您可以像在 VPC 中一樣存取 Amazon Cognito，無需使用網際網路閘道、NAT 裝置、VPN 連接或 Direct Connect 連線。VPC 中的執行個體不需要公有 IP 地址即可存取 Amazon Cognito。

您可以建立由 AWS PrivateLink提供支援的*介面端點*來建立此私有連線。我們會在您為介面端點啟用的每個子網中建立端點網路介面。這些是申請者管理的網路介面，可做為目的地為 Amazon Cognito 之流量的進入點。

如需詳細資訊，請參閱《*AWS PrivateLink 指南*》中的「[透過 AWS PrivateLink存取 AWS 服務](https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-access-aws-services.html)」。

**重要**  
透過 目前不支援下列身分驗證類型 AWS PrivateLink：  
使用 OAuth 2.0 用戶端登入資料流程的機器對機器 (M2M) 授權
使用受管登入和傳統託管 UI 登入。

**Topics**
+ [AWS PrivateLink 整合的身分驗證流程](#privatelink-authentication-flows)
+ [的操作模式 AWS PrivateLink](#privatelink-operational-modes)
+ [Amazon Cognito 的考量事項](#vpc-endpoint-considerations)
+ [使用資源控制政策控制存取](#vpc-endpoint-considerations-rcps)
+ [建立 Amazon Cognito 的介面端點](#vpc-endpoint-create)
+ [為您的介面端點建立端點政策](#vpc-endpoint-policy)
+ [建立 AWS PrivateLink 操作的身分型政策](#identity-based-vpc-policy)

## AWS PrivateLink 整合的身分驗證流程
<a name="privatelink-authentication-flows"></a>

下表說明 VPCs 中用戶端可用的身分驗證流程，以及您可以套用來管理它們的 IAM 政策。您可以在使用者集區請求中評估的政策是資源控制政策 (RCPs)、VPC 端點政策和身分型政策。


| 資源 | 身分驗證流程 | 用戶端傳輸 VPC 端點時評估的政策 | 用戶端原始伺服器為公有時評估的政策 | 
| --- | --- | --- | --- | 
| 使用者集區 | [受管登入和傳統託管 UI 登入](cognito-user-pools-managed-login.md) | 無 （無存取權）[1](#privatelink-vpc-endpoint-note) | 無[2](#privatelink-domain-note) | 
| 使用者集區 | [Machine-to-machine授權](cognito-user-pools-define-resource-servers.md#cognito-user-pools-define-resource-servers-about-m2m) | 無 （無存取權）[1](#privatelink-vpc-endpoint-note) | 無[2](#privatelink-domain-note) | 
| 使用者集區 | SDK 和 REST API 未驗證的請求 | RCPs、VPC 端點政策[3](#privatelink-no-domain-note) | RCPs | 
| 使用者集區 | SDK 和 REST API SigV4 [驗證的](authentication-flows-public-server-side.md#amazon-cognito-user-pools-server-side-authentication-flow)請求 | RCPs、VPC 端點政策、身分型政策[3](#privatelink-no-domain-note) | RCPs、身分型政策 | 
| ​身分集區 | SDK 和 REST API 未驗證的請求 ([基本](authentication-flow.md#authentication-flow-basic)和[增強](authentication-flow.md#authentication-flow-enhanced)的流程） | RCPs、VPC 端點政策 | RCPs | 
| ​身分集區 | SDK 和 REST API SigV4 驗證的請求 [（開發人員驗證](authentication-flow.md#authentication-flow-developer)的流程） | RCPs、身分型政策 | RCPs、身分型政策 | 

1 個 VPC 端點不接受使用者集區網域的請求。如果用戶端有網際網路的路由，則會套用 NAT，讓原始伺服器變成公有。

2 使用者集區網域的存在可防止傳輸 VPC 端點的任何使用者集區請求完成。任何用戶端只能將公有傳輸路徑**帶到使用者集區網域和 API 服務端點，使得 VPC 端點無法用於使用者集區。指派網域的使用者集區與 不相容 AWS PrivateLink。

3 使用者集區*不得*指派網域。

## 的操作模式 AWS PrivateLink
<a name="privatelink-operational-modes"></a>

 AWS PrivateLink 和 Amazon Cognito 支援下列範例實作模型。


| 資源 | 實作 | 動作 | 
| --- | --- | --- | 
| 使用者集區 | 全私有 SDK 或 REST API 應用程式 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/cognito/latest/developerguide/vpc-interface-endpoints.html)  | 
| 使用者集區 | 公有及私有 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/cognito/latest/developerguide/vpc-interface-endpoints.html)  | 
| 使用者集區 | 私有或公有 OAuth 2.0 授權伺服器 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/cognito/latest/developerguide/vpc-interface-endpoints.html)  | 
| ​身分集區 | 完全私有 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/cognito/latest/developerguide/vpc-interface-endpoints.html)  | 
| ​身分集區 | 公有及私有 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/cognito/latest/developerguide/vpc-interface-endpoints.html)  | 

## Amazon Cognito 的考量事項
<a name="vpc-endpoint-considerations"></a>

在您設定 Amazon Cognito 的介面端點之前，請檢閱 *AWS PrivateLink 指南*中的[考量事項](https://docs.aws.amazon.com/vpc/latest/privatelink/create-interface-endpoint.html#considerations-interface-endpoints)。Amazon Cognito 支援透過介面端點呼叫所有 Amazon Cognito API 動作。如需這些操作的詳細資訊，請參閱 [Amazon Cognito 使用者集區 API 參考](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/Welcome.html)和 [Amazon Cognito 聯合身分 API 參考](https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/Welcome.html)。

AWS PrivateLink for Amazon Cognito 僅適用於商業 AWS 區域。

**Topics**
+ [使用者集區和 AWS PrivateLink](#vpc-endpoint-considerations-user-pools)
+ [身分集區和 AWS PrivateLink](#vpc-endpoint-considerations-identity-pools)

### 使用者集區和 AWS PrivateLink
<a name="vpc-endpoint-considerations-user-pools"></a>

您可以透過介面端點向所有使用者集區 API 操作提出請求，但不能向使用者集區 OAuth 2.0 授權伺服器請求的操作提出請求，例如用戶端憑證授予和受管登入。

`cognito-idp` 使用者集區 API 具有[未驗證、已驗證和字符授權的 API 操作](authentication-flows-public-server-side.md)。您可以在 VPC 端點和資源控制政策中授予已驗證操作的許可。*您也可以*授予未驗證和字符授權操作的許可，與身分型政策不同。VPC 端點和資源控制政策類型能夠評估和拒絕或允許其他公有操作的請求。

對網域端點的請求也是公開的，但您無法在 政策中評估它們。VPC 私有 DNS 不會將使用者集區網域的請求路由到您的 VPC 端點。您只能透過公有網際網路路徑請求網域服務。如需詳細資訊，請參閱[政策對使用者集區操作的影響](#vpc-endpoint-considerations-policy-effects)。

**Topics**
+ [受支援的操作](#vpc-endpoint-considerations-supported-operations)
+ [政策對使用者集區操作的影響](#vpc-endpoint-considerations-policy-effects)

#### 受支援的操作
<a name="vpc-endpoint-considerations-supported-operations"></a>

VPC 中的系統可以將請求傳送至[使用者集區 API 動作](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncognitouserpools.html)，但*無法*傳送至使用者集區[網域端點](cognito-userpools-server-contract-reference.md)。使用網域端點的 OpenID Connect (OIDC) 和 OAuth 2.0 工作流程，例如[machine-to-machine(M2M)](cognito-user-pools-define-resource-servers.md)、[聯合登入](cognito-user-pools-identity-federation.md)和[授權碼授予](authorization-endpoint.md)，無法透過 VPC 端點存取。VPC 端點政策不會影響這些 HTTP 工作流程，而且無法處理它們。從 VPC 內對網域端點的請求一律會在介面端點失敗，但當您為使用者集區設定 VPC 端點時，仍可透過公有 DNS 和路由繼續使用。

為了防止 VPC 中的系統指派網域，Amazon Cognito 會在介面端點封鎖`CreateUserPoolDomain`請求。這可防止從 VPC 中的系統將網域新增至您的使用者集區。若要防止從所有系統新增網域，請將[資源控制政策](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps.html) (RCP)，如下列範例套用至您的 AWS 帳戶。此政策會針對指定的使用者集區封鎖`CreateUserPoolDomain`動作。

```
{
    "Version": "2012-10-17", 		 	 	 		 	 	 
    "Statement": [
        {
            "Principal": "*",
            "Effect": "Deny",
            "Action": [
                "cognito-idp:CreateUserPoolDomain"
            ],
            "Resource": "arn:aws:cognito-idp:us-east-1:123456789012:userpool/us-east-1_EXAMPLE"
        }
    ]
}
```

您的使用者集區可能有網域，而且在所有情況下都無法透過該網域使用 AWS PrivateLink。`cognito-idp` [服務端點](https://docs.aws.amazon.com/general/latest/gr/cognito.html#cognito-idp-region)的所有 SDK 型[使用者集區 API 請求](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncognitouserpools.html)都會透過 接受請求 AWS PrivateLink，但 除外`CreateUserPoolDomain`。使用者集區 API 服務端點和網域端點一律可透過公有網際網路路徑存取。若要解決來自公有來源[AWS WAF ACLs](user-pool-waf.md)。

#### 政策對使用者集區操作的影響
<a name="vpc-endpoint-considerations-policy-effects"></a>

VPC 端點政策和資源控制政策 (RCPs) 可以控制所有使用者集區 API 操作，即使是一般為公開和未經驗證的操作。您也可以使用 VPC 條件金鑰，將限制套用至身分型政策中的使用者集區存取。只有包含 [SigV4 格式](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv.html)身分驗證資訊的請求，才能在以身分為基礎的政策中控制。受管登入和傳統託管 UI 操作是單獨的類別，不符合 VPC 傳輸或將任何類型的政策套用到其動作的資格。

**未驗證的操作**  
用戶端應用程式的 Amazon Cognito 操作不會使用 SigV4 驗證。範例操作位於 的範例政策中[為您的介面端點建立端點政策建立端點政策建立身分型政策](#vpc-endpoint-policy)。未驗證操作的其他範例為 `GetUser`和 `AssociateSoftwareToken`。當您將這些操作新增至以[身分為基礎的政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_identity-vs-resource.html)時，它們沒有作用。不過，您可以在 VPC 端點政策和 [RCPs](#vpc-endpoint-considerations-rcps)存取。

未驗證的操作不會與 IAM 主體相關聯。您的 VPC 端點政策或 RCP 必須允許這些動作的所有主體。

**已驗證的操作**  
使用 SigV4 驗證使用者集區管理和伺服器端身分**驗證的 API 操作。對於已驗證的操作，您可以使用套用至 VPC 端點的[端點政策](https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints-access.html)、組織中[的資源控制政策](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps.html)，以及套用至主體的[身分型政策](#identity-based-vpc-policy)來限制主體。身分型和資源控制政策是 VPC 感知的，具有[網路型條件金鑰](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-network-properties)，例如 `aws:SourceVpc`和 `aws:SourceVpce`。

如需使用者集區之 API 操作的伺服器端、用戶端和管理類別的詳細資訊，請參閱 [API 和 SDK 身分驗證的授權模型](authentication-flows-public-server-side.md)。

### 身分集區和 AWS PrivateLink
<a name="vpc-endpoint-considerations-identity-pools"></a>

Amazon Cognito 身分集區透過 支援所有 API 操作 AWS PrivateLink。

**Topics**
+ [受支援的操作](#vpc-endpoint-considerations-identity-pools-operations)
+ [與 AWS STS 整合的網路內容限制](#vpc-endpoint-considerations-identity-pools-sts)
+ [服務特定內容索引鍵](#vpc-endpoint-considerations-identity-pools-context-keys)

#### 受支援的操作
<a name="vpc-endpoint-considerations-identity-pools-operations"></a>

透過界面端點支援所有身分集區 API 操作。身分集區沒有網域端點，也不受相同的限制。不過，身分集區因為與 整合，而對網路型存取控制有特定的考量 AWS STS。

#### 與 AWS STS 整合的網路內容限制
<a name="vpc-endpoint-considerations-identity-pools-sts"></a>

身分集區使用 AWS STS `AssumeRoleWithWebIdentity` 操作來提供臨時 AWS 登入資料。當身分集區 AWS PrivateLink 在增強型身分驗證流程中呼叫 AWS STS 時，如 `aws:SourceIp`、 `aws:SourceVpc`和 的網路內容金鑰會`aws:SourceVpce`包含來自身分集區服務基礎設施的值，而不是來自應用程式的網路內容。

如果您的 IAM 角色信任政策或資源控制政策 (RCPs) 使用網路型條件金鑰來限制存取，身分集區操作可能會意外遭到拒絕。若要解決此限制，您可以使用下列其中一種方法：

**用於服務識別的主體標籤**  
標記與身分集區搭配使用的 IAM 角色，並修改您的政策，以便在委託人具有適當的標籤時允許操作。首先，將標籤新增至您的身分集區角色：

```
aws iam tag-role \
    -\-role-name MyIdentityPoolRole \
    -\-tags Key=CognitoServiceCall,Value=true
```

然後修改以網路為基礎的政策，以允許已標記的主體。例如，在 RCP 中：

```
{
    "Version": "2012-10-17", 		 	 	 		 	 	 
    "Statement": [
        {
            "Effect": "Deny",
            "Principal": "*",
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Resource": "*",
            "Condition": {
                "NotIpAddress": {
                    "aws:SourceIp": ["allowed-ip-ranges"]
                },
                "StringNotEqualsIfExists": {
                    "aws:ResourceTag/CognitoServiceCall": "true"
                }
            }
        }
    ]
}
```

#### 服務特定內容索引鍵
<a name="vpc-endpoint-considerations-identity-pools-context-keys"></a>

身分集區提供 VPC 端點政策和 RCPs 中資源層級授權的服務特定內容金鑰。使用這些內容金鑰，您可以啟用精細存取控制，並在 政策中區分已驗證和未驗證的使用者。

**non-SigV4 操作可用的服務特定內容金鑰，例如 [GetId](https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_GetId.html)、[GetCredentialsForIdentity](https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_GetCredentialsForIdentity.html)、[GetOpenIdToken](https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_GetOpenIdToken.html)、[UnlinkIdentity](https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_UnlinkIdentity.html)**
+ `cognito-identity-unauth:IdentityPoolArn` - 依身分集區 ARN 篩選未驗證使用者的存取權
+ `cognito-identity-unauth:AccountId` - 依未驗證使用者的 AWS 帳戶 ID 篩選存取權
+ `cognito-identity-auth:IdentityPoolArn` - 依已驗證使用者的身分集區 ARN 篩選存取權
+ `cognito-identity-auth:AccountId` - 依已驗證使用者的 AWS 帳戶 ID 篩選存取權

**SigV4 操作可用的服務特定內容索引鍵，例如 [DeleteIdentities](https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_DeleteIdentities.html) 和 [DescribeIdentity](https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_DescribeIdentity.html)**
+ `cognito-identity:IdentityPoolArn` - 依身分集區 ARN 篩選存取權

您可以在 VPC 端點政策中使用這些內容金鑰，根據身分驗證狀態限制存取，如下列範例所示：

```
{
    "Version": "2012-10-17", 		 	 	 		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "cognito-identity:GetId",
                "cognito-identity:GetCredentialsForIdentity"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "cognito-identity-unauth:IdentityPoolArn": "arn:aws:cognito-identity:us-east-1:123456789012:identitypool/us-east-1:12345678-ffff-ffff-ffff-123456"
                }
            }
        }
    ]
}
```

## 使用資源控制政策控制存取
<a name="vpc-endpoint-considerations-rcps"></a>

Amazon Cognito 支援使用資源控制[政策 (RCP) 控制對資源](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps.html)RCPs存取。使用[網路型條件金鑰](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-network-properties)，RCPs可以定義允許 AWS PrivateLink 存取使用者集區和身分集區的網路和動作。RCPs 中的`Action`陳述式可以控制對已驗證和未驗證使用者集區 API 操作的存取。

例如，下列範例政策可防止從特定 VPC 存取所有使用者集區。

```
{
  "Version": "2012-10-17", 		 	 	 
  "Statement": [
    {
      "Sid": "DenyCognitoAccessOutsideVPC",
      "Effect": "Deny",
      "Principal": "*",
      "Action": "cognito-idp:*",
      "Resource": "*",
      "Condition": {
        "StringNotEqualsIfExists": {
          "aws:SourceVpc": "vpc-02d6770f46ef1653b"
        }
      }
    }
  ]
}
```

## 建立 Amazon Cognito 的介面端點
<a name="vpc-endpoint-create"></a>

您可以使用 Amazon VPC 主控台或 () 為 Amazon Cognito 建立介面端點AWS CLI。 AWS Command Line Interface 如需詳細資訊，請參閱《*AWS PrivateLink 指南*》中的「[建立介面端點](https://docs.aws.amazon.com/vpc/latest/privatelink/create-interface-endpoint.html#create-interface-endpoint-aws)」。

使用下列服務名稱建立 Amazon Cognito 使用者集區的介面端點：

```
com.amazonaws.region.cognito-idp
```

使用下列服務名稱建立 Amazon Cognito 身分集區的介面端點：

```
com.amazonaws.region.cognito-identity
```

如果您為介面端點啟用私有 DNS，您可以使用其預設的區域 DNS 名稱向 Amazon Cognito 提出 API 請求。例如，`cognito-idp.us-east-1.amazonaws.com`對於使用者集區和`cognito-identity.us-east-1.amazonaws.com`對於身分集區。

## 為您的介面端點建立端點政策
<a name="vpc-endpoint-policy"></a>

端點政策為 IAM 資源，您可將其連接至介面端點。預設端點政策允許透過介面端點完整存取 Amazon Cognito。若要控制 Amazon Cognito 從您的 VPC 允許的存取，請將自訂端點政策連接至介面端點。

端點政策會指定以下資訊：
+ 可執行動作 (AWS 帳戶、IAM 使用者和 IAM 角色) 的主體。
+ 可執行的動作。
+ 可供執行動作的資源。
+ 在允許或拒絕請求之前，必須滿足的條件。

如需詳細資訊，請參閱《*AWS PrivateLink 指南*》中的「[使用端點政策控制對服務的存取](https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints-access.html)」。

**範例：使用者集區動作的 VPC 端點政策**  
以下是使用者集區的自訂端點政策範例。當您將此政策連接到介面端點時，它會授予所有資源上所有主體所列出的使用者集區動作的存取權。

```
{
   "Version": "2012-10-17", 		 	 	 		 	 	 
   "Statement": [
      {
         "Principal": { 
            "AWS": "arn:aws:iam::123456789012:assumed-role/MyWebAppRole/MyWebAppSession"
         }, 
         "Effect": "Allow",
         "Action": [
            "cognito-idp:AdminInitiateAuth",
            "cognito-idp:AdminRespondToAuthChallenge",
            "cognito-idp:AdminSetUserPassword"
         ],
         "Resource":"arn:aws:cognito-idp:us-east-1:123456789012:userpool/us-east-1_EXAMPLE"
      },
      {
         "Effect": "Allow",
         "Action": [
            "cognito-idp:InitiateAuth",
            "cognito-idp:RespondToAuthChallenge",
            "cognito-idp:ForgotPassword",
            "cognito-idp:ConfirmForgotPassword"
         ],
         "Resource":"arn:aws:cognito-idp:us-east-1:123456789012:userpool/us-east-1_EXAMPLE"
      }
   ]
}
```

**範例：身分集區動作的 VPC 端點政策**  
以下是身分集區的自訂端點政策範例。此政策使用服務特定的內容金鑰，限制來自特定身分集區的已驗證使用者存取。

```
{
   "Version": "2012-10-17", 		 	 	 		 	 	 
   "Statement": [
      {
         "Effect": "Allow",
         "Principal": "*",
         "Action": [
            "cognito-identity:GetId",
            "cognito-identity:GetCredentialsForIdentity",
            "cognito-identity:GetOpenIdToken"
         ],
         "Resource": "*",
         "Condition": {
            "StringEquals": {
               "cognito-identity-auth:IdentityPoolArn": "arn:aws:cognito-identity:us-east-1:123456789012:identitypool/us-east-1:12345678-ffff-ffff-ffff-123456"
            }
         }
      }
   ]
}
```

## 建立 AWS PrivateLink 操作的身分型政策
<a name="identity-based-vpc-policy"></a>

[身分型政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#policies_id-based)是您可以連接到 AWS 委託人的 IAM 資源。您可以使用 IAM 驗證操作的身分型政策，透過 VPC 端點控制對 Amazon Cognito 的存取。與端點政策不同，您無法在身分型政策中設定未驗證操作的許可。驗證或管理操作需要 [Signature 第 4 版](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv.html)授權。對於使用者集區，已驗證的操作包括伺服器端身分驗證請求，例如 [AdminInitiateAuth](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminInitiateAuth.html)，以及管理請求，例如 [UpdateUserPool](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UpdateUserPool.html)。對於身分集區，已驗證的操作包含 [DeleteIdentities](https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_DeleteIdentities.html) 和 [DescribeIdentity](https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_DescribeIdentity.html) 等管理請求。

身分型政策會指定下列資訊：
+ 可執行的動作。
+ 可供執行動作的資源。
+ 在允許或拒絕請求之前，必須滿足的條件。

**範例：使用者集區伺服器端身分驗證的身分型政策**  
下列範例政策會授予從指定端點存取指定使用者集區中列出的使用者集區動作的權限。將此政策套用至 Web 應用程式的擔任 IAM 角色。

```
{
    "Version": "2012-10-17", 		 	 	 		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "cognito-idp:AdminInitiateAuth",
                "cognito-idp:AdminRespondToAuthChallenge",
                "cognito-idp:AdminSetUserPassword"
            ],
            "Resource": "arn:aws:cognito-idp:us-east-1:123456789012:userpool/us-east-1_EXAMPLE",
            "Condition": {
                "StringEquals": {
                    "aws:SourceVpce": "vpce-1a2b3c4d"
                }
            }
        }
    ]
}
```

**範例：身分集區管理操作的身分型政策**  
下列範例政策授予從指定 VPC 端點存取身分集區管理動作的權限。將此政策套用至需要執行身分集區管理的 IAM 主體。

```
{
    "Version": "2012-10-17", 		 	 	 		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "cognito-identity:DeleteIdentities",
                "cognito-identity:DescribeIdentity"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "aws:SourceVpce": "vpce-1a2b3c4d"
                },
                "StringEquals": {
                   "cognito-identity:IdentityPoolArn": "arn:aws:cognito-identity:us-east-1:123456789012:identitypool/us-east-1:12345678-ffff-ffff-ffff-123456"
                }
            }
        }
    ]
}
```