本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
啟用 Amazon RDS Data API
若要使用 Amazon RDS Data API (資料 API),請為您的 Aurora 資料庫叢集啟用它。您可以在建立或修改資料庫叢集時啟用資料 API。
注意
叢集是否可使用資料 API,取決於您的 Aurora 版本、資料庫引擎和 AWS 區域。對於較舊的 Aurora 版本,資料 API 僅適用於Aurora Serverless v1叢集。對於較新的 Aurora 版本,資料 API 適用於同時使用佈建和Aurora Serverless v2執行個體的叢集。若要檢查您的叢集是否可以使用資料 API,請參閱 RDS Data API 支援的 區域和 Aurora 資料庫引擎。
建立資料庫時啟用 RDS Data API
當您建立支援 RDS Data API (資料 API) 的資料庫時,您可以啟用此功能。下列程序說明如何在使用 AWS Management Console、 AWS CLI或 RDS API 時執行此操作。
若要在建立資料庫叢集時啟用資料 API,請選取建立資料庫頁面連線區段中的啟用 RDS 資料 API 核取方塊,如下列螢幕擷取畫面所示。

如需如何建立可使用 RDS Data API 的 Aurora 資料庫叢集的說明,請參閱下列各項:
對於 Aurora Serverless v2和 佈建的叢集 – 建立 Amazon Aurora 資料庫叢集
對於 Aurora Serverless v1 – 建立 Aurora Serverless v1 資料庫叢集
若要在建立 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 Data API (資料 API) 的資料庫叢集,以啟用或停用此功能。
啟用或停用資料 API (Aurora Serverless v2 和 已佈建)
使用下列程序啟用或停用 Aurora Serverless v2和佈建資料庫上的資料 API。若要啟用或停用Aurora Serverless v1資料庫上的資料 API,請使用 中的程序啟用或停用資料 API (Aurora Serverless v1僅限 )。
您可以使用支援此功能之資料庫叢集的 RDS 主控台來啟用或停用資料 API。若要這樣做,請開啟您要啟用或停用資料 API 之資料庫的叢集詳細資訊頁面,然後在連線與安全索引標籤上,前往 RDS Data API 區段。本節顯示資料 API 的狀態,並允許您啟用或停用它。
下列螢幕擷取畫面顯示未啟用 RDS Data API。

若要啟用或停用現有資料庫上的資料 API,請執行 enable-http-endpoint 或 disable-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,請使用 EnableHttpEndpoint 和 DisableHttpEndpoint 操作。
啟用或停用資料 API (Aurora Serverless v1僅限 )
使用下列程序啟用或停用現有Aurora Serverless v1資料庫上的資料 API。若要在 Aurora Serverless v2和佈建的資料庫上啟用或停用資料 API,請使用 中的程序啟用或停用資料 API (Aurora Serverless v2 和 已佈建)。
當您修改資料庫叢集時,您可以在 RDS Aurora Serverless v1 主控台的連線區段中啟用資料 API。
下列螢幕擷取畫面顯示修改 Aurora 資料庫叢集時啟用的資料 API。

如需如何修改Aurora Serverless v1資料庫叢集的說明,請參閱 修改 Aurora Serverless v1 資料庫叢集。
若要啟用或停用資料 API,--no-enable-http-endpoint
請視需要使用 --enable-http-endpoint
或 執行 modify-db-cluster AWS CLI 命令。
下列範例會在 上啟用資料 APIsample-cluster
。
對於 Linux、 macOS或 Unix:
aws rds modify-db-cluster \ --db-cluster-identifier sample-cluster \ --enable-http-endpoint
在 Windows 中:
aws rds modify-db-cluster ^ --db-cluster-identifier sample-cluster ^ --enable-http-endpoint
若要啟用資料 API,請使用 ModifyDBCluster 操作,並視需要將 的值設定為 EnableHttpEndpoint
true
或 false
。