

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

# 啟用 Amazon RDS 資料 API
<a name="data-api.enabling"></a>

若要使用 Amazon RDS 資料 API (資料 API)，請為 Aurora 資料庫叢集將其啟用。您可以在建立或修改資料庫叢集時啟用資料 API。

**注意**  
 叢集是否可使用資料 API，取決於您的 Aurora 版本、資料庫引擎和 AWS 區域。對於 Aurora，資料 API 適用於同時使用佈建和Aurora serverless執行個體的叢集。若要檢查叢集是否可以使用資料 API，請參閱 [RDS 資料 API 的支援區域和 Aurora 資料庫引擎](Concepts.Aurora_Fea_Regions_DB-eng.Feature.Data_API.md)。

**Topics**
+ [建立資料庫時啟用 RDS 資料 API](#data-api.enabling.creating)
+ [在現有資料庫上啟用或停用 RDS Data API](#data-api.enabling.modifying)

## 建立資料庫時啟用 RDS 資料 API
<a name="data-api.enabling.creating"></a>

當您建立的是支援 RDS 資料 API (資料 API) 的資料庫時，您可以啟用此功能。下列程序說明如何在使用 AWS 管理主控台 AWS CLI、 或 RDS API 時執行此操作。

### 主控台
<a name="data-api.enabling.creating.console"></a>

如下列螢幕擷取畫面所示，若要在建立資料庫叢集時啟用資料 API，請選取**建立資料庫**頁面的**連線**區段中**啟用 RDS 資料 API** 核取方塊。

![[建立資料庫] 頁面上的 [連線] 區段，其中已選取 [啟用 RDS 資料 API] 核取方塊。](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/data-api-enable-on-create.png)


如需如何建立可使用 RDS 資料 API 的 Aurora 資料庫叢集的說明，請參閱下文：
+ 對於 Aurora serverless 和佈建的叢集：[建立 Amazon Aurora 資料庫叢集](Aurora.CreateInstance.md)

### AWS CLI
<a name="data-api.enabling.creating.cli"></a>

若要在建立 Aurora 資料庫叢集時啟用資料 API，請使用 `--enable-http-endpoint`選項執行 [create-db-cluster](https://docs.aws.amazon.com/cli/latest/reference/rds/create-db-cluster.html) AWS CLI 命令。

下列範例會建立已啟用資料 API 的 Aurora PostgreSQL 資料庫叢集。

對於 Linux、macOS 或 Unix：

```
aws rds create-db-cluster \
	    --db-cluster-identifier {{my_pg_cluster}} \
	    --engine aurora-postgresql \
	    --enable-http-endpoint
```

在 Windows 中：

```
aws rds create-db-cluster ^
	    --db-cluster-identifier {{my_pg_cluster}} ^
	    --engine aurora-postgresql ^
	    --enable-http-endpoint
```

### RDS API
<a name="data-api.enabling.creating.api"></a>

若要在建立 Aurora 資料庫叢集時啟用資料 API，請使用 [CreateDBCluster](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBCluster.html) 操作，並將 `EnableHttpEndpoint` 參數的值設為 `true`。

## 在現有資料庫上啟用或停用 RDS Data API
<a name="data-api.enabling.modifying"></a>

您可以修改支援 RDS 資料 API (資料 API) 的資料庫叢集，即可啟用或停用此功能。

**Topics**
+ [啟用或停用資料 API (Aurora serverless 和已佈建)](#data-api.enabling.modifying.all)

### 啟用或停用資料 API (Aurora serverless 和已佈建)
<a name="data-api.enabling.modifying.all"></a>

使用下列程序啟用或停用 Aurora serverless 和佈建資料庫的資料 API。

#### 主控台
<a name="data-api.enabling.modifying.all.console"></a>

您可以使用支援此功能之資料庫叢集的 RDS 主控台，來啟用或停用資料 API。若要這樣做，請開啟您要啟用或停用資料 API 之資料庫的叢集詳細資訊頁面，然後從**動作**下拉式功能表中選取**啟用 RDS Data API** 或**停用 RDS Data API**。這可讓您啟用或停用叢集的 RDS 資料 API。

下列螢幕擷取畫面顯示未啟用的 **RDS 資料 API**。

![資料庫叢集詳細資訊頁面的 [連線和安全] 索引標籤上的 [RDS 資料 API] 區段。資料 API 的狀態會顯示為已停用，並且存在 [啟用 RDS 資料 API] 按鈕。](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/data-api-enable-from-details.png)


#### AWS CLI
<a name="data-api.enabling.modifying.all.cli"></a>

若要啟用或停用現有資料庫上的資料 API，請執行 [enable-http-endpoint](https://docs.aws.amazon.com/cli/latest/reference/rds/enable-http-endpoint.html) 或 [disable-http-endpoint](https://docs.aws.amazon.com/cli/latest/reference/rds/disable-http-endpoint.html) AWS CLI 命令，並指定資料庫叢集的 ARN。

下列範例會啟用資料 API。

對於 Linux、macOS 或 Unix：

```
aws rds enable-http-endpoint \
	    --resource-arn {{cluster_arn}}
```

在 Windows 中：

```
aws rds enable-http-endpoint ^
	    --resource-arn {{cluster_arn}}
```

#### RDS API
<a name="data-api.enabling.modifying.all.api"></a>

若要啟用或停用現有資料庫上的資料 API，請使用 [EnableHttpEndpoint](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_EnableHttpEndpoint.html) 和 [DisableHttpEndpoint](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DisableHttpEndpoint.html) 操作。