View a markdown version of this page

啟用 Amazon RDS 資料 API - Amazon Aurora

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

啟用 Amazon RDS 資料 API

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

注意

叢集是否可使用資料 API,取決於您的 Aurora 版本、資料庫引擎和 AWS 區域。對於 Aurora,資料 API 適用於同時使用佈建和Aurora Serverless v2執行個體的叢集。若要檢查叢集是否可以使用資料 API,請參閱 RDS 資料 API 的支援區域和 Aurora 資料庫引擎

建立資料庫時啟用 RDS 資料 API

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

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

[建立資料庫] 頁面上的 [連線] 區段,其中已選取 [啟用 RDS 資料 API] 核取方塊。

如需如何建立可使用 RDS 資料 API 的 Aurora 資料庫叢集的說明,請參閱下文:

若要在建立 Aurora 資料庫叢集時啟用資料 API,請使用 --enable-http-endpoint選項執行 create-db-cluster 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

若要在建立 Aurora 資料庫叢集時啟用資料 API,請使用 CreateDBCluster 操作,並將 EnableHttpEndpoint 參數的值設為 true

在現有資料庫上啟用或停用 RDS Data API

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

啟用或停用資料 API (Aurora Serverless v2 和已佈建)

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

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

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

資料庫叢集詳細資訊頁面的 [連線和安全] 索引標籤上的 [RDS 資料 API] 區段。資料 API 的狀態會顯示為已停用,並且存在 [啟用 RDS 資料 API] 按鈕。

若要啟用或停用現有資料庫上的資料 API,請執行 enable-http-endpointdisable-http-endpoint 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

若要啟用或停用現有資料庫上的資料 API,請使用 EnableHttpEndpointDisableHttpEndpoint 操作。