

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

# 將區域 API 匯入至 API Gateway
<a name="import-export-api-endpoints"></a>

當您匯入 API 時，可以選擇 API 的區域端點組態。您可以使用 API Gateway 主控台 AWS CLI、 或 AWS SDK。

當您匯出 API 時，API 端點組態不會包含在匯出的 API 定義中。

如需從 API Gateway 主控台使用「匯入 API」功能的教學課程，請參閱[教學課程：匯入範例來建立 REST API](api-gateway-create-api-from-example.md)。

**Topics**
+ [使用 API Gateway 主控台匯入區域性 API](#import-regional-api-with-console)
+ [使用 匯入區域 API AWS CLI](#import-regional-api-with-awscli)

## 使用 API Gateway 主控台匯入區域性 API
<a name="import-regional-api-with-console"></a>

若要使用 API Gateway 主控台匯入區域端點的 API，請執行下列動作：

1. 在以下網址登入 API Gateway 主控台：[https://console.aws.amazon.com/apigateway](https://console.aws.amazon.com/apigateway)。

1. 選擇 **Create API (建立 API)**。

1. 在 **REST API** 下，選擇 **Import** (匯入)。

1.  複製 API 的 OpenAPI 定義並將它貼入程式碼編輯器，或選擇**選擇檔案**，從本機磁碟機載入 OpenAPI 檔案。

1. 對於 **API 端點類型**，選取**區域**。

1.  選擇**建立 API** 以開始匯入 OpenAPI 定義。

## 使用 匯入區域 API AWS CLI
<a name="import-regional-api-with-awscli"></a>

以下 [import-rest-api](https://docs.aws.amazon.com/cli/latest/reference/apigateway/import-rest-api.html) 命令會匯入 OpenAPI 定義檔案，並將端點類型設為區域：

```
aws apigateway import-rest-api \
    --parameters endpointConfigurationTypes=REGIONAL \
    --fail-on-warnings \
    --body 'file://path/to/API_OpenAPI_template.json'
```