

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

# 搭配使用 `CreatePlacementGroup` 與 CLI
<a name="example_ec2_CreatePlacementGroup_section"></a>

下列程式碼範例示範如何使用 `CreatePlacementGroup`。

------
#### [ CLI ]

**AWS CLI**  
**建立置放群組**  
此範例命令會建立具有指定名稱的置放群組。  
命令：  

```
aws ec2 create-placement-group --group-name my-cluster --strategy cluster
```
**建立分區放置群組**  
此範例命令會建立名為 `HDFS-Group-A` 的分區放置群組，其中包含五個分區。  
命令：  

```
aws ec2 create-placement-group --group-name HDFS-Group-A --strategy partition --partition-count 5
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreatePlacementGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/create-placement-group.html)。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**範例 1：此範例會建立具有指定名稱的置放群組。**  

```
New-EC2PlacementGroup -GroupName my-placement-group -Strategy cluster
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [CreatePlacementGroup](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：此範例會建立具有指定名稱的置放群組。**  

```
New-EC2PlacementGroup -GroupName my-placement-group -Strategy cluster
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [CreatePlacementGroup](https://docs.aws.amazon.com/powershell/v5/reference)。

------

如需 AWS SDK 開發人員指南和程式碼範例的完整清單，請參閱 [使用 SDK 建立 Amazon EC2 資源 AWS](sdk-general-information-section.md)。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。