Use CreatePlacementGroup with a CLI
The following code examples show how to use CreatePlacementGroup.
- CLI
-
- Amazon CLI
-
Example 1: To create a placement group
The following
create-placement-groupexample creates a placement group with the specified name.aws ec2 create-placement-group \ --group-namemy-cluster\ --strategyclusterOutput:
{ "PlacementGroup": { "GroupName": "my-cluster", "State": "available", "Strategy": "cluster", "GroupId": "pg-0123456789example", "GroupArn": "arn:aws:ec2:us-west-2:123456789012:placement-group/my-cluster" } }For more information, see Placement groups for your Amazon EC2 instances
in the Amazon EC2 User Guide. Example 2: To create a partition placement group
The following
create-placement-groupexample creates a partition placement group namedHDFS-Group-Awith five partitions.aws ec2 create-placement-group \ --group-nameHDFS-Group-A\ --strategypartition\ --partition-count5Output:
{ "PlacementGroup": { "GroupName": "HDFS-Group-A", "State": "available", "Strategy": "partition", "PartitionCount": 5, "GroupId": "pg-0abcdef1234example", "GroupArn": "arn:aws:ec2:us-west-2:123456789012:placement-group/HDFS-Group-A" } }For more information, see Placement strategies for your placement groups
in the Amazon EC2 User Guide. -
For API details, see CreatePlacementGroup
in Amazon CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell V4
-
Example 1: This example creates a placement group with the specified name.
New-EC2PlacementGroup -GroupName my-placement-group -Strategy cluster-
For API details, see CreatePlacementGroup
in Amazon Tools for PowerShell Cmdlet Reference (V4).
-
- Tools for PowerShell V5
-
Example 1: This example creates a placement group with the specified name.
New-EC2PlacementGroup -GroupName my-placement-group -Strategy cluster-
For API details, see CreatePlacementGroup
in Amazon Tools for PowerShell Cmdlet Reference (V5).
-
For a complete list of Amazon SDK developer guides and code examples, see Create Amazon EC2 resources using an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.