

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

# AWS IoT Greengrass 和介面 VPC 端點 (AWS PrivateLink)
<a name="vpc-interface-endpoints"></a>

您可以建立*介面 VPC 端點，在 VPC* 與 AWS IoT Greengrass 控制平面之間建立私有連線。您可以使用此端點來管理 AWS IoT Greengrass 服務中的元件、部署和核心裝置。介面端點採用 [AWS PrivateLink](https://aws.amazon.com/privatelink)技術，可讓您在沒有網際網路閘道、NAT 裝置、VPN 連接或 AWS Direct Connect 連接的情況下私下存取 AWS IoT Greengrass APIs。VPC 中的執行個體不需要公有 IP 地址即可與 AWS IoT Greengrass APIs通訊。VPC 與 之間的流量 AWS IoT Greengrass 不會離開 Amazon 網路。

每個介面端點都是由您子網路中的一或多個[彈性網路介面](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html)表示。

如需詳細資訊，請參閱《Amazon VPC 使用者指南》**中的[介面 VPC 端點 (AWS PrivateLink)](https://docs.aws.amazon.com/vpc/latest/userguide/vpce-interface.html)。

**Topics**
+ [AWS IoT Greengrass VPC 端點的考量事項](#vpc-endpoint-considerations)
+ [建立 AWS IoT Greengrass 控制平面操作的介面 VPC 端點](#create-vpc-endpoint-control-plane)
+ [為 建立 VPC 端點政策 AWS IoT Greengrass](#vpc-endpoint-policy)
+ [在 VPC 中操作 AWS IoT Greengrass 核心裝置](#vpc-operate-device-vpce)

## AWS IoT Greengrass VPC 端點的考量事項
<a name="vpc-endpoint-considerations"></a>

設定介面 VPC 端點之前 AWS IoT Greengrass，請檢閱《*Amazon VPC 使用者指南*》中的[介面端點屬性和限制](https://docs.aws.amazon.com/vpc/latest/userguide/vpce-interface.html#vpce-interface-limitations)。此外，請注意下列考量事項：
+ AWS IoT Greengrass 支援從您的 VPC 呼叫其所有控制平面 API 動作。控制平面包含 [CreateDeployment](https://docs.aws.amazon.com/greengrass/v2/APIReference/API_CreateDeployment.html) 和 [ListEffectiveDeployments](https://docs.aws.amazon.com/greengrass/v2/APIReference/API_ListEffectiveDeployments.html) 等操作。控制平面*不包含* [ResolveComponentCandidates](device-auth.md#iot-policies) 和 [Discover](greengrass-discover-api.md) 等操作，這是資料平面操作。
+  AWS 中國區域 AWS IoT Greengrass 目前不支援 的 VPC 端點。

## 建立 AWS IoT Greengrass 控制平面操作的介面 VPC 端點
<a name="create-vpc-endpoint-control-plane"></a>

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

 AWS IoT Greengrass 使用下列服務名稱建立 的 VPC 端點：
+ com.amazonaws.*region*.greengrass

如果您為端點啟用私有 DNS，則可以 AWS IoT Greengrass 使用區域的預設 DNS 名稱向 提出 API 請求，例如 `greengrass.us-east-1.amazonaws.com`。預設為啟用私有 DNS。

如需詳細資訊，請參閱《Amazon VPC 使用者指南》**中的[透過介面端點存取服務](https://docs.aws.amazon.com/vpc/latest/userguide/vpce-interface.html#access-service-though-endpoint)。

## 為 建立 VPC 端點政策 AWS IoT Greengrass
<a name="vpc-endpoint-policy"></a>

您可以將端點政策連接至 VPC 端點，以控制控制平面操作的 AWS IoT Greengrass 存取。此政策會指定下列資訊：
+ 可執行動作的主體。
+ 委託人可以執行的動作。
+ 委託人可以對其執行動作的資源。

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

**Example 範例： AWS IoT Greengrass 動作的 VPC 端點政策**  
以下是 端點政策的範例 AWS IoT Greengrass。連接到端點時，此政策會授予所有資源上所有委託人的所列 AWS IoT Greengrass 動作的存取權。  

```
{
    "Statement": [
        {
            "Principal": "*",
            "Effect": "Allow",
            "Action": [
                "greengrass:CreateDeployment",
                "greengrass:ListEffectiveDeployments"
            ],
            "Resource": "*"
        }
    ]
}
```

## 在 VPC 中操作 AWS IoT Greengrass 核心裝置
<a name="vpc-operate-device-vpce"></a>

您可以操作 Greengrass 核心裝置，並在 VPC 中執行部署，而無需公有網際網路存取。您至少必須使用對應的 DNS 別名設定下列 VPC 端點。如需如何建立和使用 VPC 端點的詳細資訊，請參閱《*Amazon* [VPC 使用者指南》中的建立 VPC 端點](https://docs.aws.amazon.com/vpc/latest/privatelink/create-interface-endpoint.html#create-interface-endpoint-aws)。

**注意**  
 AWS IoT data 和 AWS IoT 登入資料的自動建立 DNS 記錄的 VPC 功能已停用。若要連接這些端點，您必須手動建立私有 DNS 記錄。如需詳細資訊，請參閱[介面端點的私有 DNS](https://docs.aws.amazon.com/vpc/latest/privatelink/create-interface-endpoint.html#vpce-private-dns)。如需 AWS IoT Core VPC 限制的詳細資訊，請參閱 [VPC 端點的限制](https://docs.aws.amazon.com/iot/latest/developerguide/IoTCore-VPC.html#VPC-limitations)。

### 先決條件
<a name="vpc-endpoint-prerequisites"></a>
+ 您必須使用手動佈建步驟安裝 AWS IoT Greengrass 核心軟體。如需詳細資訊，請參閱[使用手動資源佈建安裝 AWS IoT Greengrass 核心軟體](manual-installation.md)。

### 限制
<a name="vpc-endpoint-limitaions"></a>
+ 中國區域 和 不支援在 VPC 中操作 Greengrass 核心裝置 AWS GovCloud (US) Regions。
+ 如需 AWS IoT data 和 AWS IoT 登入資料提供者 VPC 端點限制的詳細資訊，請參閱[限制](https://docs.aws.amazon.com/iot/latest/developerguide/IoTCore-VPC.html#VPC-limitations)。

### 設定您的 Greengrass 核心裝置以在 VPC 中操作
<a name="vpc-endpoint-operate-gg-core"></a>

****

1. 取得 的 AWS IoT 端點 AWS 帳戶，並儲存它們以供稍後使用。您的裝置會使用這些端點來連線 AWS IoT。請執行下列操作：

   1. 取得 AWS IoT 的資料端點 AWS 帳戶。

      ```
      aws iot describe-endpoint --endpoint-type iot:Data-ATS
      ```

      如果請求成功，回應看起來與下列範例類似。

      ```
      {
        "endpointAddress": "device-data-prefix-ats.iot.us-west-2.amazonaws.com"
      }
      ```

   1. 取得 的 AWS IoT 登入資料端點 AWS 帳戶。

      ```
      aws iot describe-endpoint --endpoint-type iot:CredentialProvider
      ```

      如果請求成功，回應看起來與下列範例類似。

      ```
      {
        "endpointAddress": "device-credentials-prefix.credentials.iot.us-west-2.amazonaws.com"
      }
      ```

1. 為 AWS IoT data 和 AWS IoT 登入資料端點建立 Amazon VPC 界面：

   1. 導覽至 [VPC](https://console.aws.amazon.com/vpc/home#/endpoints) **端點**主控台，在左側選單的**虛擬私有雲端**下，選擇**端點**，然後選擇**建立端點**。

   1. 在**建立端點**頁面中，指定下列資訊。
      + 選擇**服務類別**的 **AWS 服務**。
      + 針對 **Service Name** (服務名稱)，輸入關鍵字 `iot` 進行搜尋。在顯示的 `iot` 服務清單中，選擇端點。

        如果您為 AWS IoT Core 資料平面建立 VPC 端點，請選擇 AWS IoT Core 您區域的資料平面 API 端點。端點的格式為 `com.amazonaws.region.iot.data`。

        如果您為 AWS IoT Core 登入資料提供者建立 VPC 端點，請選擇您區域的 AWS IoT Core 登入資料提供者端點。端點的格式為 `com.amazonaws.region.iot.credentials`。
**注意**  
中國區域中 AWS IoT Core 資料平面的服務名稱格式為 `cn.com.amazonaws.region.iot.data`。中國區域不支援為 AWS IoT Core 登入資料提供者建立 VPC 端點。
      + 針對 **VPC** 和 **Subnets** (子網路)，選擇要在其中建立端點的 VPC，以及要在其中建立端點網路的可用區域 (AZ)。
      + 針對 **Enable DNS name** (啟用 DNS 名稱)，確定未選取 **Enable for this endpoint** (為此端點啟用)。 AWS IoT Core 資料平面和 AWS IoT Core 登入資料提供者都不支援私有 DNS 名稱。
      + 針對 **Security group** (安全群組)，選擇要與端點網路介面建立關聯的安全群組。
      + 您可以選擇性地新增或移除標籤。標籤是您用來與端點建立關聯的名稱值對。

   1. 若要建立 VPC 端點，請選擇 **Create endpoint** (建立端點)。

1. 建立 AWS PrivateLink 端點之後，您會在端點**的詳細資訊**索引標籤中看到 DNS 名稱清單。您可以使用您在本節中建立的其中一個 DNS 名稱來[設定私有託管區域](https://docs.aws.amazon.com/iot/latest/developerguide/IoTCore-VPC.html#connect-iot-core-create-phz-lns)。

1. 建立 Amazon S3 端點。如需詳細資訊，請參閱[建立 Amazon S3 的 VPC 端點](https://docs.aws.amazon.com/AmazonS3/latest/userguide/privatelink-interface-endpoints.html#s3-creating-vpc)。

1. 如果您使用的是 [AWS提供的 Greengrass 元件](https://docs.aws.amazon.com/greengrass/v2/developerguide/public-components.html)，則可能需要額外的端點和組態。若要檢視端點需求，請從 AWS提供的元件清單中選取元件，然後查看需求區段。例如，[日誌管理員元件需求](log-manager-component.md#log-manager-component-requirements)建議此元件必須能夠對端點 執行傳出請求`logs.region.amazonaws.com`。

   如果您使用自己的元件，您可能需要檢閱相依性並執行其他測試，以判斷是否需要任何其他端點。

1. 在 Greengrass 核組態中， `greengrassDataPlaneEndpoint` 必須設定為 **iotdata**。如需詳細資訊，請參閱 [Greengrass 核組態](greengrass-nucleus-component.md#greengrass-nucleus-component-configuration)。

1. 如果您位於 `us-east-1`區域，請在 Greengrass 核組態**REGIONAL**中將組態參數`s3EndpointType`設定為 。此功能適用於 Greengrass 核版本 2.11.3 或更新版本。

**Example 範例：元件組態**  

```
{
"aws.greengrass.Nucleus": {
   "configuration": {
      "awsRegion": "us-east-1",
      "iotCredEndpoint": "xxxxxx.credentials.iot.region.amazonaws.com",
      "iotDataEndpoint": "xxxxxx-ats.iot.region.amazonaws.com",
      "greengrassDataPlaneEndpoint": "iotdata",
      "s3EndpointType": "REGIONAL"
      ...
     }
   }
}
```

下表提供有關對應自訂私有 DNS 別名的資訊。


| 服務 | VPC 端點服務名稱 | VPC 端點類型 | 自訂私有 DNS 別名 | 備註 | 
| --- | --- | --- | --- | --- | 
|  AWS IoT data  | `com.amazonaws.region.iot.data` | 介面 |  `prefix-ats.iot.region.amazonaws.com`  |  私有 DNS 記錄應符合您帳戶的 AWS IoT data 端點：`aws iot describe–endpoint ––endpoint–type iot:Data-ATS`。  | 
| AWS IoT 登入資料 | `com.amazonaws.region.iot.credentials` | 介面 | `prefix.credentials.iot.region.amazonaws.com` | 私有 DNS 記錄應與您的帳戶 AWS IoT 登入資料端點相符：`aws iot describe–endpoint ––endpoint–type iot:CredentialProvider`。 | 
| Amazon S3 | `com.amazonaws.region.s3` | 介面 |  | DNS 記錄會自動建立。 | 