

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 将 `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` 的分区置放群组，其中包含 5 个分区。  
命令:  

```
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 ]

**适用于 PowerShell V4 的工具**  
**示例 1：此示例命令使用指定的名称创建置放群组。**  

```
New-EC2PlacementGroup -GroupName my-placement-group -Strategy cluster
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 4) [CreatePlacementGroup](https://docs.aws.amazon.com/powershell/v4/reference)中的。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例命令使用指定的名称创建置放群组。**  

```
New-EC2PlacementGroup -GroupName my-placement-group -Strategy cluster
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [CreatePlacementGroup](https://docs.aws.amazon.com/powershell/v5/reference)中的。

------

有关 S AWS DK 开发者指南和代码示例的完整列表，请参阅[使用 AWS SDK 创建 Amazon EC2 资源](sdk-general-information-section.md)。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。