

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

# CreateCluster
<a name="API_elastic_CreateCluster"></a>

建立新的 Amazon DocumentDB 彈性叢集，並傳回其叢集結構。

## 請求語法
<a name="API_elastic_CreateCluster_RequestSyntax"></a>

```
POST /cluster HTTP/1.1
Content-type: application/json

{
   "adminUserName": "string",
   "adminUserPassword": "string",
   "authType": "string",
   "backupRetentionPeriod": number,
   "clientToken": "string",
   "clusterName": "string",
   "kmsKeyId": "string",
   "preferredBackupWindow": "string",
   "preferredMaintenanceWindow": "string",
   "shardCapacity": number,
   "shardCount": number,
   "shardInstanceCount": number,
   "subnetIds": [ "string" ],
   "tags": { 
      "string" : "string" 
   },
   "vpcSecurityGroupIds": [ "string" ]
}
```

## URI 請求參數
<a name="API_elastic_CreateCluster_RequestParameters"></a>

請求不會使用任何 URI 參數。

## 請求主體
<a name="API_elastic_CreateCluster_RequestBody"></a>

請求接受採用 JSON 格式的下列資料。

 ** [adminUserName](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-adminUserName"></a>
Amazon DocumentDB 彈性叢集管理員的名稱。  
 *限制條件*：  
+ 必須為 1 到 63 個字母或數字。
+ 第一個字元必須是字母。
+ 不能是保留字。
類型：字串  
必要：是

 ** [adminUserPassword](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-adminUserPassword"></a>
Amazon DocumentDB 彈性叢集管理員的密碼。密碼可以包含任何可列印的 ASCII 字元。  
 *限制條件*：  
+ 必須包含 8 到 100 個字元。
+ 不能包含正斜線 (/)、雙引號 (") 或 "at" 符號 (@)。
類型：字串  
必要：是

 ** [authType](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-authType"></a>
用來決定在何處擷取用於存取彈性叢集之密碼的身分驗證類型。有效類型為 `PLAIN_TEXT`或 `SECRET_ARN`。  
類型：字串  
有效值:`PLAIN_TEXT | SECRET_ARN`   
必要：是

 ** [clusterName](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-clusterName"></a>
新彈性叢集的名稱。此參數是以小寫字母字串的形式儲存。  
 *限制條件*：  
+ 必須包含 1 到 63 個字母、數字或連字號。
+ 第一個字元必須是字母。
+ 不能以連字號結尾，或包含兩個連續連字號。
 *範例*：`my-cluster`  
類型：字串  
必要：是

 ** [shardCapacity](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-shardCapacity"></a>
指派給每個彈性叢集碎片vCPUs 數目。上限為 64。允許的值為 2、4、8、16、32、64。  
類型：整數  
必要：是

 ** [shardCount](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-shardCount"></a>
指派給彈性叢集的碎片數量。上限為 32。  
類型：整數  
必要：是

 ** [backupRetentionPeriod](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-backupRetentionPeriod"></a>
保留自動快照的天數。  
類型：整數  
必要：否

 ** [clientToken](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-clientToken"></a>
彈性叢集的用戶端字符。  
類型：字串  
必要：否

 ** [kmsKeyId](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-kmsKeyId"></a>
用來加密新彈性叢集的 KMS 金鑰識別符。  
KMS 金鑰識別符是 KMS 加密金鑰的 Amazon Resource Name (ARN)。如果您使用擁有此 KMS 加密金鑰的相同 Amazon 帳戶建立叢集，您可以使用 KMS 金鑰別名，而非 ARN 做為 KMS 加密金鑰。  
如果未指定加密金鑰，Amazon DocumentDB 會使用 KMS 為您的帳戶建立的預設加密金鑰。您的帳戶在每個 Amazon 區域都有不同的預設加密金鑰。  
類型：字串  
必要：否

 ** [preferredBackupWindow](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-preferredBackupWindow"></a>
如果啟用自動備份，則建立自動備份的每日時間範圍，由 決定`backupRetentionPeriod`。  
類型：字串  
必要：否

 ** [preferredMaintenanceWindow](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-preferredMaintenanceWindow"></a>
每週可能進行系統維護的時段，以國際標準時間 (UTC) 表示。  
 *格式*：`ddd:hh24:mi-ddd:hh24:mi`  
 *預設*：從每個 8 小時的時段中隨機選取的 30 分鐘時段 AWS 區域，發生在一週中的隨機一天。  
 *有效天數*：週一、週二、週三、週四、週五、週六、週日  
 *限制條件*：必須至少是 30 分鐘的時段。  
類型：字串  
必要：否

 ** [shardInstanceCount](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-shardInstanceCount"></a>
套用至彈性叢集中所有碎片的複本執行個體數目。`shardInstanceCount` 值 1 表示有一個寫入器執行個體，而任何其他執行個體都是可用於讀取和改善可用性的複本。  
類型：整數  
必要：否

 ** [subnetIds](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-subnetIds"></a>
新彈性叢集的 Amazon EC2 IDs。  
類型：字串陣列  
必要：否

 ** [tags](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-tags"></a>
要指派給新彈性叢集的標籤。  
類型：字串到字串映射  
索引鍵長度限制：長度下限為 1。長度上限為 128。  
金鑰模式：`(?!aws:)[a-zA-Z+-=._:/]+`  
值長度限制：長度下限為 0。長度上限為 256。  
必要：否

 ** [vpcSecurityGroupIds](#API_elastic_CreateCluster_RequestSyntax) **   <a name="documentdb-elastic_CreateCluster-request-vpcSecurityGroupIds"></a>
要與新彈性叢集建立關聯的 EC2 VPC 安全群組清單。  
類型：字串陣列  
必要：否

## 回應語法
<a name="API_elastic_CreateCluster_ResponseSyntax"></a>

```
HTTP/1.1 200
Content-type: application/json

{
   "cluster": { 
      "adminUserName": "string",
      "authType": "string",
      "backupRetentionPeriod": number,
      "clusterArn": "string",
      "clusterEndpoint": "string",
      "clusterName": "string",
      "createTime": "string",
      "kmsKeyId": "string",
      "preferredBackupWindow": "string",
      "preferredMaintenanceWindow": "string",
      "shardCapacity": number,
      "shardCount": number,
      "shardInstanceCount": number,
      "shards": [ 
         { 
            "createTime": "string",
            "shardId": "string",
            "status": "string"
         }
      ],
      "status": "string",
      "subnetIds": [ "string" ],
      "vpcSecurityGroupIds": [ "string" ]
   }
}
```

## 回應元素
<a name="API_elastic_CreateCluster_ResponseElements"></a>

如果動作成功，則服務傳回 HTTP 200 回應。

服務會傳回下列 JSON 格式的資料。

 ** [cluster](#API_elastic_CreateCluster_ResponseSyntax) **   <a name="documentdb-elastic_CreateCluster-response-cluster"></a>
已建立的新彈性叢集。  
類型：[Cluster](API_elastic_Cluster.md) 物件

## 錯誤
<a name="API_elastic_CreateCluster_Errors"></a>

如需所有動作常見錯誤的資訊，請參閱[常見錯誤](CommonErrors.md)。

 ** AccessDeniedException **   
當沒有足夠的許可來執行動作時，就會發生例外狀況。    
 ** message **   
錯誤訊息，說明拒絕存取的原因。
HTTP 狀態碼：403

 ** ConflictException **   
發生存取衝突。    
 ** resourceId **   
發生存取衝突的資源 ID。  
 ** resourceType **   
發生存取衝突的資源類型。
HTTP 狀態碼：409

 ** InternalServerException **   
發生內部伺服器錯誤。  
HTTP 狀態碼：500

 ** ServiceQuotaExceededException **   
已超過 動作的服務配額。  
HTTP 狀態碼：402

 ** ThrottlingException **   
當請求因請求調節而遭拒時，將會擲回 ThrottlingException。    
 ** retryAfterSeconds **   
重試操作之前要等待的秒數。
HTTP 狀態碼：429

 ** ValidationException **   
定義驗證例外狀況的結構。    
 ** fieldList **   
發生驗證例外狀況的欄位清單。  
 ** message **   
描述驗證例外狀況的錯誤訊息。  
 ** reason **   
驗證例外發生的原因 (`unknownOperation`、`fieldValidationFailed`、 `cannotParse`或 之一`other`)。
HTTP 狀態碼：400

## 另請參閱
<a name="API_elastic_CreateCluster_SeeAlso"></a>

如需在其中一種語言特定 AWS SDKs中使用此 API 的詳細資訊，請參閱下列內容：
+  [AWS 命令列界面 V2](https://docs.aws.amazon.com/goto/cli2/docdb-elastic-2022-11-28/CreateCluster) 
+  [AWS 適用於 .NET V4 的 SDK](https://docs.aws.amazon.com/goto/DotNetSDKV4/docdb-elastic-2022-11-28/CreateCluster) 
+  [AWS 適用於 C\$1\$1 的 SDK](https://docs.aws.amazon.com/goto/SdkForCpp/docdb-elastic-2022-11-28/CreateCluster) 
+  [AWS 適用於 Go 的 SDK v2](https://docs.aws.amazon.com/goto/SdkForGoV2/docdb-elastic-2022-11-28/CreateCluster) 
+  [AWS 適用於 Java V2 的 SDK](https://docs.aws.amazon.com/goto/SdkForJavaV2/docdb-elastic-2022-11-28/CreateCluster) 
+  [AWS 適用於 JavaScript V3 的 SDK](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/docdb-elastic-2022-11-28/CreateCluster) 
+  [AWS 適用於 Kotlin 的 SDK](https://docs.aws.amazon.com/goto/SdkForKotlin/docdb-elastic-2022-11-28/CreateCluster) 
+  [AWS 適用於 PHP V3 的 SDK](https://docs.aws.amazon.com/goto/SdkForPHPV3/docdb-elastic-2022-11-28/CreateCluster) 
+  [AWS 適用於 Python 的 SDK](https://docs.aws.amazon.com/goto/boto3/docdb-elastic-2022-11-28/CreateCluster) 
+  [AWS 適用於 Ruby V3 的 SDK](https://docs.aws.amazon.com/goto/SdkForRubyV3/docdb-elastic-2022-11-28/CreateCluster) 