本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
啟用 Amazon RDS 資料 API
若要使用 Amazon RDS 資料 API (資料 API),請為 Aurora 資料庫叢集將其啟用。您可以在建立或修改資料庫叢集時啟用資料 API。
注意
叢集是否可使用資料 API,取決於 Aurora 版本、資料庫引擎和 AWS區域。對於較舊的 Aurora 版本,資料 API 僅適用於 Aurora Serverless v1 叢集。對於較新的 Aurora 版本,資料 API 適用於同時使用佈建和 Aurora Serverless v2 執行個體的叢集。若要檢查叢集是否可以使用資料 API,請參閱 RDS 資料 API 的支援區域和 Aurora 資料庫引擎。
建立資料庫時啟用 RDS 資料 API
當您建立的是支援 RDS 資料 API (資料 API) 的資料庫時,您可以啟用此功能。下列程序說明如何在使用 AWS Management Console、AWS CLI 或 RDS API 時執行此操作。
如下列螢幕擷取畫面所示,若要在建立資料庫叢集時啟用資料 API,請選取建立資料庫頁面的連線區段中啟用 RDS 資料 API 核取方塊。
如需如何建立可使用 RDS 資料 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-identifiermy_pg_cluster\ --engine aurora-postgresql \ --enable-http-endpoint
在 Windows 中:
aws rds create-db-cluster ^ --db-cluster-identifiermy_pg_cluster^ --engine aurora-postgresql ^ --enable-http-endpoint
若要在建立 Aurora 資料庫叢集時啟用資料 API,請使用 CreateDBCluster 操作,並將 EnableHttpEndpoint 參數的值設為 true。
在現有資料庫啟用 RDS 資料 API
您可以修改支援 RDS 資料 API (資料 API) 的資料庫叢集,即可啟用或停用此功能。
啟用或停用資料 API (Aurora Serverless v2 和已佈建)
使用下列程序啟用或停用 Aurora Serverless v2 和佈建資料庫的資料 API。若要啟用或停用在 Aurora Serverless v1 資料庫的資料 API,請使用 啟用或停用資料 API (僅限 Aurora Serverless v1) 中的程序。
您可以使用支援此功能之資料庫叢集的 RDS 主控台,來啟用或停用資料 API。若要這樣做,請開啟您要啟用或停用資料 API 之資料庫的叢集詳細資訊頁面,然後在連線與安全索引標籤,前往 RDS 資料 API 區段。本節顯示資料 API 的狀態,並允許您將其啟用或停用。
下列螢幕擷取畫面顯示未啟用的 RDS 資料 API。
若要啟用或停用現有資料庫上的資料 API,請執行 enable-http-endpoint 或 disable-http-endpoint AWS CLI 命令,並指定資料庫叢集的 ARN。
下列範例會啟用資料 API。
對於 Linux、macOS 或 Unix:
aws rds enable-http-endpoint \ --resource-arncluster_arn
在 Windows 中:
aws rds enable-http-endpoint ^ --resource-arncluster_arn
若要啟用或停用現有資料庫上的資料 API,請使用 EnableHttpEndpoint 和 DisableHttpEndpoint 操作。
啟用或停用資料 API (僅限 Aurora Serverless v1)
使用下列程序來啟用或停用現有 Aurora Serverless v1 資料庫的資料 API。若要在 Aurora Serverless v2 和佈建的資料庫啟用或停用資料 API,請使用 啟用或停用資料 API (Aurora Serverless v2 和已佈建) 中的程序。
修改 Aurora Serverless v1 資料庫叢集時,在 RDS 主控台的連線 區段中啟用資料 API。
下列螢幕擷取畫面顯示修改 Aurora DB 資料庫叢集時啟用的資料 API。
如需如何修改 Aurora Serverless v1 資料庫叢集的指示,請參閱修改 Aurora Serverless v1 資料庫叢集。
若要啟用或停用資料 API,請視需要使用 --enable-http-endpoint 或 --no-enable-http-endpoint 執行 modify-db-cluster AWS CLI 命令。
下列範例會在 sample-cluster 啟用資料 API。
對於 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。